Package mars.util
Class StringTrie<V>
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes all of the mappings from this map (optional operation).booleancontainsKey(Object key) Returnstrueif this map contains a mapping for the specified key.booleancontainsValue(Object value) Returnstrueif this map maps one or more keys to the specified value.entrySet()Returns aSetview of the mappings contained in this map.Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.getKey()getSubTrie(String key) Associates the specified value with the specified key in this map (optional operation).Removes the mapping for a key from this map if it is present (optional operation).voidsetTerminalValue(V value) Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, putAll, size, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
StringTrie
public StringTrie() -
StringTrie
-
-
Method Details
-
getKey
-
getTerminalValue
-
setTerminalValue
-
getSubTrie
-
getSubTrieIfPresent
-
containsKey
Returnstrueif this map contains a mapping for the specified key. More formally, returnstrueif and only if this map contains a mapping for a keyksuch thatObjects.equals(key, k). (There can be at most one such mapping.)- Specified by:
containsKeyin interfaceMap<String,V> - Overrides:
containsKeyin classAbstractMap<String,V> - Parameters:
key- key whose presence in this map is to be tested- Returns:
trueif this map contains a mapping for the specified key- Throws:
ClassCastException- if the key is of an inappropriate type for this mapNullPointerException- if the specified key is null
-
containsValue
Returnstrueif this map maps one or more keys to the specified value. More formally, returnstrueif and only if this map contains at least one mapping to a valuevsuch thatObjects.equals(value, v). This operation will probably require time linear in the map size.- Specified by:
containsValuein interfaceMap<String,V> - Overrides:
containsValuein classAbstractMap<String,V> - Parameters:
value- value whose presence in this map is to be tested- Returns:
trueif this map maps one or more keys to the specified value- Throws:
ClassCastException- if the value is of an inappropriate type for this mapNullPointerException- if the specified value is null
-
get
Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.More formally, if this map contains a mapping from a key
kto a valuevsuch thatObjects.equals(key, k), then this method returnsv; otherwise it returnsnull. (There can be at most one such mapping.)If this map permits null values, then a return value of
nulldoes not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull. ThecontainsKeyoperation may be used to distinguish these two cases.- Specified by:
getin interfaceMap<String,V> - Overrides:
getin classAbstractMap<String,V> - Parameters:
key- the key whose associated value is to be returned- Returns:
- the value to which the specified key is mapped, or
nullif this map contains no mapping for the key - Throws:
ClassCastException- if the key is of an inappropriate type for this mapNullPointerException- if the specified key is null
-
put
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A mapmis said to contain a mapping for a keykif and only ifm.containsKey(k)would returntrue.)- Specified by:
putin interfaceMap<String,V> - Overrides:
putin classAbstractMap<String,V> - Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. - Throws:
NullPointerException- if the specified key or value is null
-
remove
Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from keykto valuevsuch thatObjects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)Returns the value to which this map previously associated the key, or
nullif the map contained no mapping for the key.The map will not contain a mapping for the specified key once the call returns.
- Specified by:
removein interfaceMap<String,V> - Overrides:
removein classAbstractMap<String,V> - Parameters:
key- key whose mapping is to be removed from the map- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. - Throws:
ClassCastException- if the key is of an inappropriate type for this mapNullPointerException- if the specified key is null
-
clear
public void clear()Removes all of the mappings from this map (optional operation). The map will be empty after this call returns. -
entrySet
Returns aSetview of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's ownremoveoperation, or through thesetValueoperation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via theIterator.remove,Set.remove,removeAll,retainAllandclearoperations. It does not support theaddoraddAlloperations.
-