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 TypeMethodDescriptionvoid
clear()
Removes all of the mappings from this map (optional operation).boolean
containsKey
(Object key) Returnstrue
if this map contains a mapping for the specified key.boolean
containsValue
(Object value) Returnstrue
if this map maps one or more keys to the specified value.entrySet()
Returns aSet
view of the mappings contained in this map.Returns the value to which the specified key is mapped, ornull
if 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).void
setTerminalValue
(V value) Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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
Returnstrue
if this map contains a mapping for the specified key. More formally, returnstrue
if and only if this map contains a mapping for a keyk
such thatObjects.equals(key, k)
. (There can be at most one such mapping.)- Specified by:
containsKey
in interfaceMap<String,
V> - Overrides:
containsKey
in classAbstractMap<String,
V> - Parameters:
key
- key whose presence in this map is to be tested- Returns:
true
if 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
Returnstrue
if this map maps one or more keys to the specified value. More formally, returnstrue
if and only if this map contains at least one mapping to a valuev
such thatObjects.equals(value, v)
. This operation will probably require time linear in the map size.- Specified by:
containsValue
in interfaceMap<String,
V> - Overrides:
containsValue
in classAbstractMap<String,
V> - Parameters:
value
- value whose presence in this map is to be tested- Returns:
true
if 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, ornull
if this map contains no mapping for the key.More formally, if this map contains a mapping from a key
k
to a valuev
such 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
null
does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull
. ThecontainsKey
operation may be used to distinguish these two cases.- Specified by:
get
in interfaceMap<String,
V> - Overrides:
get
in 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
null
if 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 mapm
is said to contain a mapping for a keyk
if and only ifm.containsKey(k)
would returntrue
.)- Specified by:
put
in interfaceMap<String,
V> - Overrides:
put
in 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
, ornull
if 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 keyk
to valuev
such 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
null
if 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:
remove
in interfaceMap<String,
V> - Overrides:
remove
in classAbstractMap<String,
V> - Parameters:
key
- key whose mapping is to be removed from the map- Returns:
- the previous value associated with
key
, ornull
if 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 aSet
view 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 ownremove
operation, or through thesetValue
operation 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
,retainAll
andclear
operations. It does not support theadd
oraddAll
operations.
-