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>| 构造器和说明 |
|---|
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.
|
| 限定符和类型 | 方法和说明 |
|---|---|
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, toStringcompute, 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 在接口中 Map<CharSequence,V>put 在类中 AbstractMap<CharSequence,V>public V get(Object key)
get 在接口中 Map<CharSequence,V>get 在类中 AbstractMap<CharSequence,V>public String getBestMatch(CharSequence str)
public boolean containsKey(Object key)
containsKey 在接口中 Map<CharSequence,V>containsKey 在类中 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 在接口中 Map<CharSequence,V>remove 在类中 AbstractMap<CharSequence,V>public void clear()
clear 在接口中 Map<CharSequence,V>clear 在类中 AbstractMap<CharSequence,V>public int size()
size 在接口中 Map<CharSequence,V>size 在类中 AbstractMap<CharSequence,V>public Set<CharSequence> keySet()
keySet 在接口中 Map<CharSequence,V>keySet 在类中 AbstractMap<CharSequence,V>public Set<Map.Entry<CharSequence,V>> entrySet()
entrySet 在接口中 Map<CharSequence,V>entrySet 在类中 AbstractMap<CharSequence,V>public Collection<V> values()
values 在接口中 Map<CharSequence,V>values 在类中 AbstractMap<CharSequence,V>public TrieMap<V> subMap(CharSequence prefix)
prefix - The prefix which to use for the sub map.Copyright © 2022. All rights reserved.