Interface IndexedReadOnlyStringMap

All Superinterfaces:
ReadOnlyStringMap, Serializable
All Known Subinterfaces:
IndexedStringMap
All Known Implementing Classes:
SortedArrayStringMap

public interface IndexedReadOnlyStringMap extends ReadOnlyStringMap
An extension of ReadOnlyStringMap that imposes a total ordering on its keys. The map is ordered according to the natural ordering of its keys. This order is reflected when consuming the key-value pairs with a BiConsumer or a TriConsumer.

This interface views all key-value pairs as a sequence ordered by key, and allows keys and values to be accessed by their index in the sequence.

Since:
2.8
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    getKeyAt(int index)
    Viewing all key-value pairs as a sequence sorted by key, this method returns the key at the specified index, or null if the specified index is less than zero or greater or equal to the size of this collection.
    <V> V
    getValueAt(int index)
    Viewing all key-value pairs as a sequence sorted by key, this method returns the value at the specified index, or null if the specified index is less than zero or greater or equal to the size of this collection.
    int
    Viewing all key-value pairs as a sequence sorted by key, this method returns the index of the specified key in that sequence.

    Methods inherited from interface org.apache.logging.log4j.util.ReadOnlyStringMap

    containsKey, forEach, forEach, getValue, isEmpty, size, toMap
  • Method Details

    • getKeyAt

      String getKeyAt(int index)
      Viewing all key-value pairs as a sequence sorted by key, this method returns the key at the specified index, or null if the specified index is less than zero or greater or equal to the size of this collection.
      Parameters:
      index - the index of the key to return
      Returns:
      the key at the specified index or null
    • getValueAt

      <V> V getValueAt(int index)
      Viewing all key-value pairs as a sequence sorted by key, this method returns the value at the specified index, or null if the specified index is less than zero or greater or equal to the size of this collection.
      Parameters:
      index - the index of the value to return
      Returns:
      the value at the specified index or null
    • indexOfKey

      int indexOfKey(String key)
      Viewing all key-value pairs as a sequence sorted by key, this method returns the index of the specified key in that sequence. If the specified key is not found, this method returns (-(insertion point) - 1).
      Parameters:
      key - the key whose index in the ordered sequence of keys to return
      Returns:
      the index of the specified key or (-(insertion point) - 1) if the key is not found. The insertion point is defined as the point at which the key would be inserted into the array: the index of the first element in the range greater than the key, or size() if all elements are less than the specified key. Note that this guarantees that the return value will be >= 0 if and only if the key is found.