List instances.
In this documentation, the terms greatest, greater, least, and lesser are considered to refer to the comparator on the elements, and the terms first and last are considered to refer to the elements' ordering in a list.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum | SortedLists.
A specification for which index to return if the list contains no elements that compare as equal to the key. |
| pack-priv static enum | SortedLists.
A specification for which index to return if the list contains at least one element that compares as equal to the key. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static <E extends Comparable | binarySearch(List<? extends E> list, E e, SortedLists.
Searches the specified naturally ordered list for the specified object using the binary search algorithm. |
| public static <E extends @Nullable Object, K extends Comparable | binarySearch(List<E> list, Function<? super E, K> keyFunction, K key, SortedLists.
Binary searches the list for the specified key, using the specified key function. |
| public static <E extends @Nullable Object, K extends @Nullable Object> int | binarySearch(List<E> list, Function<? super E, K> keyFunction, K key, Comparator<? super K> keyComparator, SortedLists.
Binary searches the list for the specified key, using the specified key function. |
| public static <E extends @Nullable Object> int | Returns: the index determined by theKeyPresentBehavior, if the key is in the list;
otherwise the index determined by the KeyAbsentBehavior.the list to be searched. list, E the value to be searched for. key, Comparator<? super E> the comparator by which the list is ordered. comparator, SortedLists.the specification for what to do if at least one element of the list
compares as equal to the key. presentBehavior,the specification for what to do if no elements of the list compare as
equal to the key. absentBehaviorSearches the specified list for the specified object using the binary search algorithm. |
| SortedLists | back to summary |
|---|---|
| private SortedLists() | |
| binarySearch | back to summary |
|---|---|
| public static <E extends Comparable Searches the specified naturally ordered list for the specified object using the binary search algorithm. Equivalent to
| |
| binarySearch | back to summary |
|---|---|
| public static <E extends @Nullable Object, K extends Comparable Binary searches the list for the specified key, using the specified key function. Equivalent to
| |
| binarySearch | back to summary |
|---|---|
| public static <E extends @Nullable Object, K extends @Nullable Object> int binarySearch(List<E> list, Function<? super E, K> keyFunction, K key, Comparator<? super K> keyComparator, SortedLists. Binary searches the list for the specified key, using the specified key function. Equivalent to | |
| binarySearch | back to summary |
|---|---|
| public static <E extends @Nullable Object> int binarySearch(List<? extends E> list, E key, Comparator<? super E> comparator, SortedLists. Searches the specified list for the specified object using the binary search algorithm. The
list must be sorted into ascending order according to the specified comparator (as by the
If there are elements in the list which compare as equal to the key, the choice of This method runs in log(n) time on random-access lists, which offer near-constant-time access to each list element.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final SortedLists. | INVERTED_INSERTION_INDEX
Return |
| public static final SortedLists. | NEXT_HIGHER
Return the index of the next higher element in the list, or |
| public static final SortedLists. | NEXT_LOWER
Return the index of the next lower element in the list, or |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract int | |
| public static SortedLists. | |
| public static SortedLists. |
| INVERTED_INSERTION_INDEX | back to summary |
|---|---|
| public static final SortedLists. Return Note that the return value will be This is equivalent to the behavior of | |
| NEXT_HIGHER | back to summary |
|---|---|
| public static final SortedLists. Return the index of the next higher element in the list, or | |
| NEXT_LOWER | back to summary |
|---|---|
| public static final SortedLists. Return the index of the next lower element in the list, or | |
| KeyAbsentBehavior | back to summary |
|---|---|
| private KeyAbsentBehavior() | |
| resultIndex | back to summary |
|---|---|
| pack-priv abstract int resultIndex(int higherIndex) | |
| valueOf | back to summary |
|---|---|
| public static SortedLists. | |
| values | back to summary |
|---|---|
| public static SortedLists. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final SortedLists. | ANY_PRESENT
Return the index of any list element that compares as equal to the key. |
| public static final SortedLists. | FIRST_AFTER
Return the index of the first list element that compares as greater than the key, or |
| public static final SortedLists. | FIRST_PRESENT
Return the index of the first list element that compares as equal to the key. |
| public static final SortedLists. | LAST_BEFORE
Return the index of the last list element that compares as less than the key, or |
| public static final SortedLists. | LAST_PRESENT
Return the index of the last list element that compares as equal to the key. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract <E extends @Nullable Object> int | |
| public static SortedLists. | |
| public static SortedLists. |
| ANY_PRESENT | back to summary |
|---|---|
| public static final SortedLists. Return the index of any list element that compares as equal to the key. No guarantees are made as to which index is returned, if more than one element compares as equal to the key. | |
| FIRST_AFTER | back to summary |
|---|---|
| public static final SortedLists. Return the index of the first list element that compares as greater than the key, or | |
| FIRST_PRESENT | back to summary |
|---|---|
| public static final SortedLists. Return the index of the first list element that compares as equal to the key. | |
| LAST_BEFORE | back to summary |
|---|---|
| public static final SortedLists. Return the index of the last list element that compares as less than the key, or | |
| LAST_PRESENT | back to summary |
|---|---|
| public static final SortedLists. Return the index of the last list element that compares as equal to the key. | |
| KeyPresentBehavior | back to summary |
|---|---|
| private KeyPresentBehavior() | |
| resultIndex | back to summary |
|---|---|
| pack-priv abstract <E extends @Nullable Object> int resultIndex(Comparator<? super E> comparator, E key, List<? extends E> list, int foundIndex) | |
| valueOf | back to summary |
|---|---|
| public static SortedLists. | |
| values | back to summary |
|---|---|
| public static SortedLists. | |