Sorted map implementation based on a red-black tree and implementing
all the methods from the NavigableMap interface.
clone
public Object clone()
comparator
public Comparator comparator()
containsKey
public boolean containsKey(Object key)
containsValue
public boolean containsValue(Object value)
descendingKeySet
public NavigableSet descendingKeySet()
Returns a reverse order
NavigableSet
view of the keys contained in this map.
The set's iterator returns the keys in descending order.
The set is backed by the map, so changes to the map are reflected in
the set, and vice-versa. If the map is modified while an iteration
over the set is in progress (except through the iterator's own
remove
operation), the results of the iteration are undefined. The
set supports element removal, which removes the corresponding mapping
from the map, via the
Iterator.remove
,
Set.remove
,
removeAll
,
retainAll
, and
clear
operations.
It does not support the
add
or
addAll
operations.
- descendingKeySet in interface NavigableMap
- a reverse order navigable set view of the keys in this map
entrySet
public Set entrySet()
firstKey
public Object firstKey()
get
public Object get(Object key)
headMap
public SortedMap headMap(Object toKey)
Equivalent to headMap(toKey, false)
.
- headMap in interface NavigableMap
headMap
public NavigableMap headMap(Object toKey,
boolean toInclusive)
Returns a view of the portion of this map whose keys are less than (or
equal to, if
inclusive
is true)
toKey
. The returned
map is backed by this map, so changes in the returned map are reflected
in this map, and vice-versa. The returned map supports all optional
map operations that this map supports.
The returned map will throw an
IllegalArgumentException
on an attempt to insert a key outside its range.
- headMap in interface NavigableMap
toKey
- high endpoint of the keys in the returned map
- a view of the portion of this map whose keys are less than
(or equal to, if
inclusive
is true) toKey
isEmpty
public boolean isEmpty()
lastKey
public Object lastKey()
navigableKeySet
public NavigableSet navigableKeySet()
Returns a
NavigableSet
view of the keys contained in this map.
The set's iterator returns the keys in ascending order.
The set is backed by the map, so changes to the map are reflected in
the set, and vice-versa. If the map is modified while an iteration
over the set is in progress (except through the iterator's own
remove
operation), the results of the iteration are undefined. The
set supports element removal, which removes the corresponding mapping
from the map, via the
Iterator.remove
,
Set.remove
,
removeAll
,
retainAll
, and
clear
operations.
It does not support the
add
or
addAll
operations.
- navigableKeySet in interface NavigableMap
- a navigable set view of the keys in this map
put
public Object put(Object key,
Object value)
putAll
public void putAll(Map map)
remove
public Object remove(Object key)
subMap
public SortedMap subMap(Object fromKey,
Object toKey)
Equivalent to subMap(fromKey, true, toKey, false)
.
- subMap in interface NavigableMap
subMap
public NavigableMap subMap(Object fromKey,
boolean fromInclusive,
Object toKey,
boolean toInclusive)
Returns a view of the portion of this map whose keys range from
fromKey
to
toKey
. If
fromKey
and
toKey
are equal, the returned map is empty unless
fromExclusive
and
toExclusive
are both true. The
returned map is backed by this map, so changes in the returned map are
reflected in this map, and vice-versa. The returned map supports all
optional map operations that this map supports.
The returned map will throw an
IllegalArgumentException
on an attempt to insert a key outside of its range, or to construct a
submap either of whose endpoints lie outside its range.
- subMap in interface NavigableMap
fromKey
- low endpoint of the keys in the returned mapfromInclusive
- true
if the low endpoint
is to be included in the returned viewtoKey
- high endpoint of the keys in the returned maptoInclusive
- true
if the high endpoint
is to be included in the returned view
- a view of the portion of this map whose keys range from
fromKey
to toKey
tailMap
public SortedMap tailMap(Object fromKey)
Equivalent to tailMap(fromKey, true)
.
- tailMap in interface NavigableMap
tailMap
public NavigableMap tailMap(Object fromKey,
boolean fromInclusive)
Returns a view of the portion of this map whose keys are greater than (or
equal to, if
inclusive
is true)
fromKey
. The returned
map is backed by this map, so changes in the returned map are reflected
in this map, and vice-versa. The returned map supports all optional
map operations that this map supports.
The returned map will throw an
IllegalArgumentException
on an attempt to insert a key outside its range.
- tailMap in interface NavigableMap
fromKey
- low endpoint of the keys in the returned map
- a view of the portion of this map whose keys are greater than
(or equal to, if
inclusive
is true) fromKey