E - the type of elements in this listpublic interface Column<E> extends List<E>, NavigableSet<E>
E are
packed/unpacked to and from the buffers. There are four variants for each
element type, with different tradeoffs between performance and functionality.
The methods isNonnull(), isSorted(), and
isDistinct() can be used to query the characteristics() of
a column:
| Database Terminology |
isNonnull | isSorted | isDistinct | Spliteratorcharacteristics |
Get by Index /RandomAccess |
Find by Value/ Binary Search |
|---|---|---|---|---|---|---|
| Heap, NULL | FALSE | FALSE | FALSE | ORDERED, IMMUTABLE |
O(n) / FALSE | O(n) / FALSE |
| Heap, NOT NULL | TRUE | FALSE | FALSE | ORDERED, IMMUTABLE,NONNULL |
O(1) / TRUE | O(n) / FALSE |
| Index | TRUE | TRUE | FALSE | ORDERED, IMMUTABLE,NONNULL, SORTED |
O(1) / TRUE | O(log(n)) / TRUE |
| Unique Index | TRUE | TRUE | TRUE | ORDERED, IMMUTABLE,NONNULL, SORTED,DISTINCT |
O(1) / TRUE | O(log(n)) / TRUE |
Additional Notes
DISTINCT implies SORTED implies NONNULL.
SIZED,
SUBSIZED, and IMMUTABLE
in addition to the ones listed above.
List and NavigableSet.
List is the primary interface, and all List methods are
always available. NavigableSet operations are only available for
unique indices (i.e., when isDistinct() -> true). They will
throw UnsupportedOperationException otherwise.
| Modifier and Type | Field and Description |
|---|---|
static int |
BASE_CHARACTERISTICS |
| Modifier and Type | Method and Description |
|---|---|
Column<E> |
append(Column<E> tail)
Appends two columns with the same element type.
|
default Column<E> |
append(Column<E> tail,
boolean coerce)
Appends two columns with the same element type.
|
int |
characteristics()
Returns the
Spliterator.characteristics() for this column. |
Column<E> |
copy()
Returns a column equal to this one, but with elements stored in a newly
allocated buffer.
|
ColumnType |
getType() |
Column<E> |
head(E toElement)
Same behavior as
head(Object, boolean), with inclusive set
to false. |
Column<E> |
head(E toElement,
boolean inclusive)
Returns a view of the portion of this column whose elements are less than (or
equal to, if
inclusive is true) toElement. |
default boolean |
isDistinct()
Returns true if the
Spliterator.DISTINCT flag is set. |
default boolean |
isNonnull()
Returns true if the
Spliterator.NONNULL flag is set. |
boolean |
isNull(int index)
Test if a value is null at a given index.
|
default boolean |
isSorted()
Returns true if the
Spliterator.SORTED flag is set. |
default Spliterator<E> |
spliterator()
Creates a
Spliterator over the elements in this list. |
Column<E> |
subColumn(E fromElement,
boolean fromInclusive,
E toElement,
boolean toInclusive)
Returns a view of the portion of this column whose elements range from
fromElement to toElement. |
Column<E> |
subColumn(E fromElement,
E toElement)
Same behavior as
Column#subColumn(Object, boolean, Object, Boolean),
with fromInclusive set to true and toInclusive set to false. |
Column<E> |
subColumn(int fromIndex,
int toIndex)
Returns a view of the portion of this column between the specified
fromIndex, inclusive, and toIndex, exclusive.
|
Column<E> |
tail(E fromElement)
Same behavior as
tail(Object, boolean), with inclusive set
to true. |
Column<E> |
tail(E fromElement,
boolean inclusive)
Returns a view of the portion of this column whose elements are greater than
(or equal to, if
inclusive is true) fromElement. |
Column<E> |
toDistinct()
Converts a column to a unique index.
|
Column<E> |
toHeap()
Converts an index into a heap.
|
Column<E> |
toSorted()
Converts a heap to an index.
|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, subList, toArray, toArrayceiling, descendingIterator, descendingSet, floor, headSet, headSet, higher, iterator, lower, pollFirst, pollLast, subSet, subSet, tailSet, tailSetcomparator, first, lastparallelStream, removeIf, streamstatic final int BASE_CHARACTERISTICS
int characteristics()
Spliterator.characteristics() for this column.default boolean isNonnull()
Spliterator.NONNULL flag is set.NONNULL flag is set.default boolean isSorted()
Spliterator.SORTED flag is set.SORTED flag is set.default boolean isDistinct()
Spliterator.DISTINCT flag is set.DISTINCT flag is set.Column<E> toHeap()
isSorted() as
false. The resulting column shares the same underlying buffer as this
one.Column<E> toSorted()
characteristics() of this column:
SORTED flag
set. If not already sorted then copy() will be invoked, and the
resulting column will be sorted.
DISTINCT flag unset.
UnsupportedOperationException - if the NONNULL flag is not setColumn<E> toDistinct()
characteristics() of this column:
SORTED and DISTINCT flags set. If not already sorted and
distinct then copy() will be invoked, and the resulting column will
be sorted and deduplicated.
DISTINCT
flag set. If duplicates are present then copy() will be invoked, and
the resulting column will be deduplicated.
UnsupportedOperationException - if the NONNULL flag is not setColumnType getType()
type.boolean isNull(int index)
index - the index to testColumn<E> subColumn(int fromIndex, int toIndex)
fromIndex - low endpoint (inclusive) of the subListtoIndex - high endpoint (exclusive) of the subListIndexOutOfBoundsException - for an illegal endpoint index value
(fromIndex < 0 || toIndex > size ||
fromIndex > toIndex)Column<E> subColumn(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive)
fromElement to toElement. If fromElement and
toElement are equal, the returned column is empty unless fromInclusive and toInclusive are both true. The returned column is
backed by this column.
This method is only available when isDistinct() returns
true.
fromElement - low endpoint of the returned columnfromInclusive - true if the low endpoint is to be included in the
returned viewtoElement - high endpoint of the returned columntoInclusive - true if the high endpoint is to be included in the
returned viewfromElement to toElementUnsupportedOperationException - if isDistinct() return falseClassCastException - if fromElement and
toElement do not match type
ENullPointerException - if fromElement or
toElement is nullIllegalArgumentException - if fromElement is greater than
toElementColumn<E> subColumn(E fromElement, E toElement)
Column#subColumn(Object, boolean, Object, Boolean),
with fromInclusive set to true and toInclusive set to false.
This method is only available when isDistinct() returns
true.
fromElement - low endpoint of the returned column, inclusivetoElement - high endpoint of the returned column, exclusivefromElement, inclusive, to toElement, exclusiveColumn<E> head(E toElement, boolean inclusive)
inclusive is true) toElement. The returned
column is backed by this column.
This method is only available when isDistinct() returns
true.
toElement - high endpoint of the returned columninclusive - true if the high endpoint is to be included in the
returned viewinclusive is true) toElementUnsupportedOperationException - if isDistinct() return falseClassCastException - if toElement is not compatible
with this column's element type.NullPointerException - if toElement is nullColumn<E> head(E toElement)
head(Object, boolean), with inclusive set
to false.
This method is only available when isDistinct() returns
true.
toElement - high endpoint of the returned columntoElementColumn<E> tail(E fromElement, boolean inclusive)
inclusive is true) fromElement. The returned
column is backed by this column.
This method is only available when isDistinct() returns
true.
fromElement - low endpoint of the returned columninclusive - true if the low endpoint is to be included in the
returned viewfromElementUnsupportedOperationException - if isDistinct() return falseClassCastException - if fromElement is not
compatible with this column's element
type.NullPointerException - if fromElement is nullColumn<E> tail(E fromElement)
tail(Object, boolean), with inclusive set
to true.
This method is only available when isDistinct() returns
true.
fromElement - low endpoint of the returned columnfromElementdefault Spliterator<E> spliterator()
Spliterator over the elements in this list.
The Spliterator reports SIZED,
SUBSIZED, ORDERED,
and IMMUTABLE.
spliterator in interface Collection<E>spliterator in interface Iterable<E>spliterator in interface List<E>spliterator in interface Set<E>spliterator in interface SortedSet<E>Spliterator over the elements in this columnColumn<E> append(Column<E> tail)
Both columns must have the same characteristics. If they're both unique indices then the first value of the provided column must be greater than the last value of this column.
tail - - the column to be appended to the end of this columndefault Column<E> append(Column<E> tail, boolean coerce)
If coerce is true and one of the columns is sorted, the sorted column will be
converted to a heap before appending. Otherwise this method behaves like
append(Column)
tail - - the column to be appended to the end of this columncoerce - - specifies if a sole sorted column should be converted to a
heapCopyright © 2019. All rights reserved.