com.github.andrewoma.dexx.collection
Interface SortedMap<K,V>

All Superinterfaces:
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
 SortedMap<K,V> asSortedMap()
          Returns an immutable view of this map as an instance of java.util.SortedMap.
 Comparator<? super K> comparator()
          Returns the comparator associated with this map, or null if the default ordering is used.
 SortedMap<K,V> drop(int number)
          Returns a map containing all elements in this map, excluding the first number of elements.
 Pair<K,V> first()
          Returns the first entry in the map or null if the map is empty.
 SortedMap<K,V> from(K key, boolean inclusive)
          Returns the bottom of the map starting from the key specified.
 Pair<K,V> last()
          Returns the last entry in the map or null if the map is empty.
 SortedMap<K,V> put(K key, V value)
          Returns a map with the value specified associated to the key specified.
 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.
 SortedMap<K,V> remove(K key)
          Returns a map with the value associated with the key removed if it exists.
 SortedMap<K,V> take(int number)
          Returns a list containing the first number of elements from this list.
 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.Map
asMap, containsKey, get, keys, values
 
Methods inherited from interface com.github.andrewoma.dexx.collection.Iterable
iterator
 
Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable
forEach, isEmpty, makeString, makeString, size, to, toArray, toArray, toIndexedList, toSet, toSortedSet
 

Method Detail

put

@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
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
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
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
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
Pair<K,V> first()
Returns the first entry in the map or null if the map is empty.


last

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


drop

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


take

@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.



Copyright © 2014. All Rights Reserved.