Interface SortedMap<K,V>

All Superinterfaces:
Iterable<Pair<K,V>>, Iterable<Pair<K,V>>, Map<K,V>, Traversable<Pair<K,V>>
All Known Implementing Classes:
AbstractSortedMap, TreeMap

public interface SortedMap<K,V> extends Map<K,V>
SortedMap defines the interface for maps that are sorted by their key.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns an immutable view of this map as an instance of java.util.SortedMap.
    Comparator<? super K>
    Returns the comparator associated with this map, or null if the default ordering is used.
    @NotNull SortedMap<K,V>
    drop(int number)
    Returns a map containing all elements in this map, excluding the first number of elements.
    @Nullable Pair<K,V>
    Returns the first entry in the map or null if the map is empty.
    @NotNull SortedMap<K,V>
    from(K key, boolean inclusive)
    Returns the bottom of the map starting from the key specified.
    @Nullable Pair<K,V>
    Returns the last entry in the map or null if the map is empty.
    @NotNull SortedMap<K,V>
    put(K key, V value)
    Returns a map with the value specified associated to the key specified.
    @NotNull SortedMap<K,V>
    range(K from, boolean fromInclusive, K to, boolean toInclusive)
    Returns a subset of the map between the from and to keys specified.
    @NotNull SortedMap<K,V>
    remove(K key)
    Returns a map with the value associated with the key removed if it exists.
    @NotNull SortedMap<K,V>
    take(int number)
    Returns a list containing the first number of elements from this list.
    @NotNull SortedMap<K,V>
    to(K key, boolean inclusive)
    Returns the top of the map up until the key specified.

    Methods inherited from interface com.github.andrewoma.dexx.collection.Iterable

    iterator

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator

    Methods inherited from interface com.github.andrewoma.dexx.collection.Map

    asMap, containsKey, get, keys, values

    Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable

    forEach, isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet
  • Method Details

    • put

      @NotNull @NotNull SortedMap<K,V> put(@NotNull K key, V value)
      Description copied from interface: Map
      Returns a map with the value specified associated to the key specified.

      If value already exists for the key, it will be replaced.

      Specified by:
      put in interface Map<K,V>
    • remove

      @NotNull @NotNull SortedMap<K,V> remove(@NotNull K key)
      Description copied from interface: Map
      Returns a map with the value associated with the key removed if it exists.
      Specified by:
      remove in interface Map<K,V>
    • from

      @NotNull @NotNull SortedMap<K,V> from(@NotNull K key, boolean inclusive)
      Returns the bottom of the map starting from the key specified.
      Parameters:
      inclusive - if true, the key will be included in the result, otherwise it will be excluded
    • to

      @NotNull @NotNull SortedMap<K,V> to(@NotNull K key, boolean inclusive)
      Returns the top of the map up until the key specified.
      Parameters:
      inclusive - if true, the key will be included in the result, otherwise it will be excluded
    • range

      @NotNull @NotNull SortedMap<K,V> range(@NotNull K from, boolean fromInclusive, @NotNull K to, boolean toInclusive)
      Returns a subset of the map between the from and to keys specified.
      Parameters:
      fromInclusive - if true, the key will be included in the result, otherwise it will be excluded
      toInclusive - if true, the key will be included in the result, otherwise it will be excluded
    • comparator

      Comparator<? super K> comparator()
      Returns the comparator associated with this map, or null if the default ordering is used.
    • first

      @Nullable @Nullable Pair<K,V> first()
      Returns the first entry in the map or null if the map is empty.
    • last

      @Nullable @Nullable Pair<K,V> last()
      Returns the last entry in the map or null if the map is empty.
    • drop

      @NotNull @NotNull SortedMap<K,V> drop(int number)
      Returns a map containing all elements in this map, excluding the first number of elements.
    • take

      @NotNull @NotNull SortedMap<K,V> take(int number)
      Returns a list containing the first number of elements from this list.
    • asSortedMap

      @NotNull SortedMap<K,V> asSortedMap()
      Returns an immutable view of this map as an instance of java.util.SortedMap.