public class UnmodifiableSortedMap<K,V> extends UnmodifiableMap<K,V> implements java.util.SortedMap<K,V>
SortedMap
prohibiting all calls which would
modify its contents. As the construction of this class is performed in
constant time it is prefered over copying the map (which takes linear time).
Using this class is also preferred to using the unmodifiableX()
in class Collections
as they return the collection base type that
does not signal, that the object ist unmodifiable. Using the classes in this
package makes unmodifiability more explicit.
All prohibited methods throw an UnsupportedOperationException
. The
class is nearly the same as the one returned by
Collections.unmodifiableSortedMap(SortedMap)
, but by making it a
public class we can make the return value of some methods more explicit.
Constructor and Description |
---|
UnmodifiableSortedMap(java.util.SortedMap<K,V> m)
Creates a new unmodifiable sorted map from another sorted map.
|
Modifier and Type | Method and Description |
---|---|
java.util.Comparator<? super K> |
comparator() |
K |
firstKey() |
UnmodifiableSortedMap<K,V> |
headMap(K toKey) |
K |
lastKey() |
UnmodifiableSortedMap<K,V> |
subMap(K fromKey,
K toKey) |
UnmodifiableSortedMap<K,V> |
tailMap(K fromKey) |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
public UnmodifiableSortedMap(java.util.SortedMap<K,V> m)
public java.util.Comparator<? super K> comparator()
public UnmodifiableSortedMap<K,V> headMap(K toKey)