Enum SortedLists.KeyAbsentBehavior

java.lang.Object
java.lang.Enum<SortedLists.KeyAbsentBehavior>
org.magicwerk.brownies.collections.helper.SortedLists.KeyAbsentBehavior
All Implemented Interfaces:
Serializable, Comparable<SortedLists.KeyAbsentBehavior>, java.lang.constant.Constable
Enclosing class:
SortedLists

public static enum SortedLists.KeyAbsentBehavior extends 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 Details

    • 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, or list.size() if there is no such element.
    • INVERTED_INSERTION_INDEX

      public static final SortedLists.KeyAbsentBehavior INVERTED_INSERTION_INDEX
      Return ~insertionIndex, where insertionIndex 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, or list.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.

  • Constructor Details

    • KeyAbsentBehavior

      private KeyAbsentBehavior()
  • Method Details

    • values

      public static SortedLists.KeyAbsentBehavior[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static SortedLists.KeyAbsentBehavior valueOf(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:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • resultIndex

      public abstract int resultIndex(int higherIndex)