K
- the type of the keys in this mapV
- the type of the values in this mappublic class UnmodifiableTrie<K,V> extends Object implements Trie<K,V>, Serializable, Unmodifiable
Trie
.Constructor and Description |
---|
UnmodifiableTrie(Trie<K,? extends V> trie)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
Comparator<? super K> |
comparator() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object obj) |
K |
firstKey()
Gets the first key currently in this map.
|
V |
get(Object key) |
int |
hashCode() |
SortedMap<K,V> |
headMap(K toKey) |
boolean |
isEmpty() |
Set<K> |
keySet() |
K |
lastKey()
Gets the last key currently in this map.
|
OrderedMapIterator<K,V> |
mapIterator()
Obtains an
OrderedMapIterator over the map. |
K |
nextKey(K key)
Gets the next key after the one specified.
|
SortedMap<K,V> |
prefixMap(K key)
Returns a view of this
Trie of all elements that are prefixed
by the given key. |
K |
previousKey(K key)
Gets the previous key before the one specified.
|
V |
put(K key,
V value)
Note that the return type is Object, rather than V as in the Map interface.
|
void |
putAll(Map<? extends K,? extends V> m) |
V |
remove(Object key) |
int |
size() |
SortedMap<K,V> |
subMap(K fromKey,
K toKey) |
SortedMap<K,V> |
tailMap(K fromKey) |
String |
toString() |
static <K,V> Trie<K,V> |
unmodifiableTrie(Trie<K,? extends V> trie)
Factory method to create a unmodifiable trie.
|
Collection<V> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public UnmodifiableTrie(Trie<K,? extends V> trie)
trie
- the trie to decorate, must not be nullNullPointerException
- if trie is nullpublic static <K,V> Trie<K,V> unmodifiableTrie(Trie<K,? extends V> trie)
K
- the key typeV
- the value typetrie
- the trie to decorate, must not be nullNullPointerException
- if trie is nullpublic Collection<V> values()
public void clear()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in interface Get<K,V>
key
- key whose presence in this map is to be testedtrue
if this map contains a mapping for the specified
keyMap.containsKey(Object)
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in interface Get<K,V>
value
- value whose presence in this map is to be testedtrue
if this map maps one or more keys to the
specified valueMap.containsValue(Object)
public boolean isEmpty()
public V put(K key, V value)
Put
put
in interface Map<K,V>
put
in interface Put<K,V>
key
- key with which the specified value is to be associatedvalue
- value to be associated with the specified keykey
, or
null
if there was no mapping for key
.
(A null
return can also indicate that the map
previously associated null
with key
,
if the implementation supports null
values.)Map.put(Object, Object)
public int size()
public K firstKey()
OrderedMap
public K lastKey()
OrderedMap
public SortedMap<K,V> prefixMap(K key)
Trie
Trie
of all elements that are prefixed
by the given key.
In a Trie
with fixed size keys, this is essentially a
Map.get(Object)
operation.
For example, if the Trie
contains 'Anna', 'Anael',
'Analu', 'Andreas', 'Andrea', 'Andres', and 'Anatole', then
a lookup of 'And' would return 'Andreas', 'Andrea', and 'Andres'.
public Comparator<? super K> comparator()
comparator
in interface SortedMap<K,V>
public OrderedMapIterator<K,V> mapIterator()
OrderedMap
OrderedMapIterator
over the map.
A ordered map iterator is an efficient way of iterating over maps in both directions.
mapIterator
in interface IterableGet<K,V>
mapIterator
in interface OrderedMap<K,V>
public K nextKey(K key)
OrderedMap
nextKey
in interface OrderedMap<K,V>
key
- the key to search for next frompublic K previousKey(K key)
OrderedMap
previousKey
in interface OrderedMap<K,V>
key
- the key to search for previous frompublic int hashCode()
Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.