Package mars.util

Class StringTrie<V>

java.lang.Object
java.util.AbstractMap<String,V>
mars.util.StringTrie<V>
All Implemented Interfaces:
Map<String,V>

public class StringTrie<V> extends AbstractMap<String,V>
  • Constructor Details

    • StringTrie

      public StringTrie()
    • StringTrie

      public StringTrie(String key)
  • Method Details

    • getKey

      public String getKey()
    • getTerminalValue

      public V getTerminalValue()
    • setTerminalValue

      public void setTerminalValue(V value)
    • getSubTrie

      public StringTrie<V> getSubTrie(String key)
    • getSubTrieIfPresent

      public StringTrie<V> getSubTrieIfPresent(String key)
    • containsKey

      public boolean containsKey(Object key)
      Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains a mapping for a key k such that Objects.equals(key, k). (There can be at most one such mapping.)
      Specified by:
      containsKey in interface Map<String,V>
      Overrides:
      containsKey in class AbstractMap<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 map
      NullPointerException - if the specified key is null
    • containsValue

      public boolean containsValue(Object value)
      Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that Objects.equals(value, v). This operation will probably require time linear in the map size.
      Specified by:
      containsValue in interface Map<String,V>
      Overrides:
      containsValue in class AbstractMap<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 map
      NullPointerException - if the specified value is null
    • get

      public V get(Object key)
      Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

      More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (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 to null. The containsKey operation may be used to distinguish these two cases.

      Specified by:
      get in interface Map<String,V>
      Overrides:
      get in class AbstractMap<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 map
      NullPointerException - if the specified key is null
    • put

      public V put(String key, V value)
      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 map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)
      Specified by:
      put in interface Map<String,V>
      Overrides:
      put in class AbstractMap<String,V>
      Parameters:
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key
      Returns:
      the previous value associated with key, or null if there was no mapping for key.
      Throws:
      NullPointerException - if the specified key or value is null
    • remove

      public V remove(Object key)
      Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.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 interface Map<String,V>
      Overrides:
      remove in class AbstractMap<String,V>
      Parameters:
      key - key whose mapping is to be removed from the map
      Returns:
      the previous value associated with key, or null if there was no mapping for key.
      Throws:
      ClassCastException - if the key is of an inappropriate type for this map
      NullPointerException - 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.
      Specified by:
      clear in interface Map<String,V>
      Overrides:
      clear in class AbstractMap<String,V>
    • entrySet

      public Set<Map.Entry<String,V>> entrySet()
      Returns a Set 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 own remove operation, or through the setValue 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 the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
      Specified by:
      entrySet in interface Map<String,V>
      Specified by:
      entrySet in class AbstractMap<String,V>
      Returns:
      a set view of the mappings contained in this map