Interface SortedMap<K,V>
-
- All Superinterfaces:
Iterable<Pair<K,V>>
,java.lang.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.SortedMap<K,V>
asSortedMap()
Returns an immutable view of this map as an instance ofjava.util.SortedMap
.java.util.Comparator<? super K>
comparator()
Returns the comparator associated with this map, ornull
if the default ordering is used.@NotNull SortedMap<K,V>
drop(int number)
Returns a map containing all elements in this map, excluding the firstnumber
of elements.@Nullable Pair<K,V>
first()
Returns the first entry in the map ornull
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>
last()
Returns the last entry in the map ornull
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 thefrom
andto
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 firstnumber
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.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 Detail
-
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.
-
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.
-
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 thefrom
andto
keys specified.- Parameters:
fromInclusive
- if true, the key will be included in the result, otherwise it will be excludedtoInclusive
- if true, the key will be included in the result, otherwise it will be excluded
-
comparator
java.util.Comparator<? super K> comparator()
Returns the comparator associated with this map, ornull
if the default ordering is used.
-
first
@Nullable @Nullable Pair<K,V> first()
Returns the first entry in the map ornull
if the map is empty.
-
last
@Nullable @Nullable Pair<K,V> last()
Returns the last entry in the map ornull
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 firstnumber
of elements.
-
take
@NotNull @NotNull SortedMap<K,V> take(int number)
Returns a list containing the firstnumber
of elements from this list.
-
-