Package com.google.common.collect
Enum SortedLists.KeyAbsentBehavior
- java.lang.Object
-
- java.lang.Enum<SortedLists.KeyAbsentBehavior>
-
- com.google.common.collect.SortedLists.KeyAbsentBehavior
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<SortedLists.KeyAbsentBehavior>
- Enclosing class:
- SortedLists
public static enum SortedLists.KeyAbsentBehavior extends java.lang.Enum<SortedLists.KeyAbsentBehavior>
A specification for which index to return if the list contains no elements that compare as equal to the key.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description INVERTED_INSERTION_INDEX
Return~insertionIndex
, whereinsertionIndex
is defined as the point at which the key would be inserted into the list: the index of the next higher element in the list, orlist.size()
if there is no such element.NEXT_HIGHER
Return the index of the next higher element in the list, orlist.size()
if there is no such element.NEXT_LOWER
Return the index of the next lower element in the list, or-1
if there is no such element.
-
Constructor Summary
Constructors Modifier Constructor Description private
KeyAbsentBehavior()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract int
resultIndex(int higherIndex)
static SortedLists.KeyAbsentBehavior
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static SortedLists.KeyAbsentBehavior[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NEXT_LOWER
public static final SortedLists.KeyAbsentBehavior NEXT_LOWER
Return the index of the next lower element in the list, or-1
if there is no such element.
-
NEXT_HIGHER
public static final SortedLists.KeyAbsentBehavior NEXT_HIGHER
Return the index of the next higher element in the list, orlist.size()
if there is no such element.
-
INVERTED_INSERTION_INDEX
public static final SortedLists.KeyAbsentBehavior INVERTED_INSERTION_INDEX
Return~insertionIndex
, whereinsertionIndex
is defined as the point at which the key would be inserted into the list: the index of the next higher element in the list, orlist.size()
if there is no such element.Note that the return value will be
>= 0
if and only if there is an element of the list that compares as equal to the key.This is equivalent to the behavior of
Collections.binarySearch(List, Object)
when the key isn't present, since~insertionIndex
is equal to-1 - insertionIndex
.
-
-
Method Detail
-
values
public static SortedLists.KeyAbsentBehavior[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (SortedLists.KeyAbsentBehavior c : SortedLists.KeyAbsentBehavior.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static SortedLists.KeyAbsentBehavior valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
resultIndex
abstract int resultIndex(int higherIndex)
-
-