V - The value type that the trie holds.public class TrieMap<V> extends AbstractMap<CharSequence,V> implements Serializable, Map<CharSequence,V>
Map interface, this implementation offers
methods to check if a key prefix is contained, get the best matching key from
an example key and retrieve prefixed views on the map.
This map does not support null keys, instead an empty string should be used.
The implementation uses nested HashMaps with Character keys
internally to ensure O(k) performance where k is
the length of an existing key, keyLen is the key which is used
for retrieval or modification operations and k ≤ keyLen.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
TrieMap()
Constructs an empty TrieMap
|
TrieMap(Map<CharSequence,? extends V> map)
Constructs a new TrieMap with the values from the given map.
|
TrieMap(TrieMap<? extends V> map)
Constructs a new TrieMap by deep cloning the internally used nodes.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsKeyPrefix(CharSequence prefix)
Returns true when an entry exists that that has the given prefix.
|
Set<Map.Entry<CharSequence,V>> |
entrySet() |
V |
get(Object key) |
String |
getBestMatch(CharSequence str) |
Set<CharSequence> |
keySet() |
V |
put(CharSequence key,
V value) |
V |
remove(Object o) |
int |
size() |
TrieMap<V> |
subMap(CharSequence prefix)
Returns a view on the current map that acts like if every method call to
the current map where a key is involved would be prefixed with the given
prefix.
|
Collection<V> |
values() |
clone, containsValue, equals, hashCode, isEmpty, putAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAllpublic TrieMap()
public TrieMap(Map<CharSequence,? extends V> map)
map - The map from which to construct this TrieMappublic V put(CharSequence key, V value)
put in interface Map<CharSequence,V>put in class AbstractMap<CharSequence,V>public V get(Object key)
get in interface Map<CharSequence,V>get in class AbstractMap<CharSequence,V>public String getBestMatch(CharSequence str)
public boolean containsKey(Object key)
containsKey in interface Map<CharSequence,V>containsKey in class AbstractMap<CharSequence,V>public boolean containsKeyPrefix(CharSequence prefix)
prefix - The prefix for which to check if an entry is contained.public V remove(Object o)
remove in interface Map<CharSequence,V>remove in class AbstractMap<CharSequence,V>public void clear()
clear in interface Map<CharSequence,V>clear in class AbstractMap<CharSequence,V>public int size()
size in interface Map<CharSequence,V>size in class AbstractMap<CharSequence,V>public Set<CharSequence> keySet()
keySet in interface Map<CharSequence,V>keySet in class AbstractMap<CharSequence,V>public Set<Map.Entry<CharSequence,V>> entrySet()
entrySet in interface Map<CharSequence,V>entrySet in class AbstractMap<CharSequence,V>public Collection<V> values()
values in interface Map<CharSequence,V>values in class AbstractMap<CharSequence,V>public TrieMap<V> subMap(CharSequence prefix)
prefix - The prefix which to use for the sub map.Copyright © 2020 Blazebit. All rights reserved.