|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections4.trie.UnmodifiableTrie<K,V>
public class UnmodifiableTrie<K,V>
An unmodifiable Trie
.
Constructor Summary | |
---|---|
UnmodifiableTrie(Trie<K,V> trie)
Constructor that wraps (not copies). |
Method Summary | ||
---|---|---|
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 a MapIterator 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
|
unmodifiableTrie(Trie<K,V> trie)
Factory method to create a unmodifiable trie. |
|
Collection<V> |
values()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UnmodifiableTrie(Trie<K,V> trie)
trie
- the trie to decorate, must not be null
IllegalArgumentException
- if trie is nullMethod Detail |
---|
public static <K,V> UnmodifiableTrie<K,V> unmodifiableTrie(Trie<K,V> trie)
K
- the key typeV
- the value typetrie
- the trie to decorate, must not be null
IllegalArgumentException
- if trie is nullpublic Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in interface Get<K,V>
Map.entrySet()
public Set<K> keySet()
keySet
in interface Map<K,V>
keySet
in interface Get<K,V>
Map.keySet()
public Collection<V> values()
values
in interface Map<K,V>
values
in interface Get<K,V>
Map.values()
public void clear()
clear
in interface Map<K,V>
clear
in interface Put<K,V>
Map.clear()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in interface Get<K,V>
Map.containsKey(Object)
public boolean containsValue(Object value)
containsValue
in interface Map<K,V>
containsValue
in interface Get<K,V>
Map.containsValue(Object)
public V get(Object key)
get
in interface Map<K,V>
get
in interface Get<K,V>
Map.get(Object)
public boolean isEmpty()
isEmpty
in interface Map<K,V>
isEmpty
in interface Get<K,V>
Map.isEmpty()
public V put(K key, V value)
Put
put
in interface Map<K,V>
put
in interface Put<K,V>
Map.put(Object, Object)
public void putAll(Map<? extends K,? extends V> m)
putAll
in interface Map<K,V>
putAll
in interface Put<K,V>
Map.putAll(Map)
public V remove(Object key)
remove
in interface Map<K,V>
remove
in interface Get<K,V>
Map.remove(Object)
public int size()
size
in interface Map<K,V>
size
in interface Get<K,V>
Map.size()
public K firstKey()
OrderedMap
firstKey
in interface SortedMap<K,V>
firstKey
in interface OrderedMap<K,V>
public SortedMap<K,V> headMap(K toKey)
headMap
in interface SortedMap<K,V>
public K lastKey()
OrderedMap
lastKey
in interface SortedMap<K,V>
lastKey
in interface OrderedMap<K,V>
public SortedMap<K,V> subMap(K fromKey, K toKey)
subMap
in interface SortedMap<K,V>
public SortedMap<K,V> tailMap(K fromKey)
tailMap
in interface SortedMap<K,V>
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'.
prefixMap
in interface Trie<K,V>
key
- the key used in the search
SortedMap
view of this Trie
with all elements whose
key is prefixed by the search keypublic Comparator<? super K> comparator()
comparator
in interface SortedMap<K,V>
public OrderedMapIterator<K,V> mapIterator()
IterableGet
MapIterator
over the map.
A map iterator is an efficient way of iterating over maps. There is no need to access the entry set or use Map Entry objects.
IterableMapmap = new HashedMap (); MapIterator it = map.mapIterator(); while (it.hasNext()) { String key = it.next(); Integer value = it.getValue(); it.setValue(value + 1); }
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 from
public K previousKey(K key)
OrderedMap
previousKey
in interface OrderedMap<K,V>
key
- the key to search for previous from
public int hashCode()
hashCode
in interface Map<K,V>
hashCode
in class Object
public boolean equals(Object obj)
equals
in interface Map<K,V>
equals
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |