Class StringPrefixMap<V>

java.lang.Object
org.wpilib.util.collections.prefixmap.StringPrefixMap<V>
Type Parameters:
V - The type of the value that is to be stored.
All Implemented Interfaces:
Map<String,V>, PrefixMap<V>

public class StringPrefixMap<V> extends Object implements PrefixMap<V>
The StringPrefixMap is an implementation of PrefixMap where the assumption is that the stored prefixes can be any character in a String.
  • Constructor Details

    • StringPrefixMap

      public StringPrefixMap()
      Constructor.
  • Method Details

    • containsPrefix

      public boolean containsPrefix(PrimitiveIterator.OfInt prefix)
      Description copied from interface: PrefixMap
      Returns true if this map contains an exact mapping for the specified prefix.
      Specified by:
      containsPrefix in interface PrefixMap<V>
      Parameters:
      prefix - prefix whose presence in this prefixmap is to be checked
      Returns:
      true if this map contains an the exact mapping for the specified prefix.
    • put

      public V put(String prefix, V value)
      Description copied from interface: PrefixMap
      Stored the specified value as the result for the specified prefix.

      If for the specified prefix previously a value was present then the old value is replaced with the new value and the old value is returned.

      Specified by:
      put in interface Map<String,V>
      Specified by:
      put in interface PrefixMap<V>
      Parameters:
      prefix - prefix with which the specified value is to be associated
      value - value to be associated with the specified prefix
      Returns:
      the previous value of the specified prefix, or null if there was no mapping for prefix.
    • size

      public int size()
      Description copied from interface: PrefixMap
      Return the number of prefix-value mappings in this prefixmap.
      Specified by:
      size in interface Map<String,V>
      Specified by:
      size in interface PrefixMap<V>
      Returns:
      the number of prefix-value mappings in this prefixmap
    • clear

      public void clear()
      Description copied from interface: PrefixMap
      The prefixmap will be empty after this call returns.
      Specified by:
      clear in interface Map<String,V>
      Specified by:
      clear in interface PrefixMap<V>
    • remove

      public V remove(String prefix)
      Description copied from interface: PrefixMap
      Removes the mapping for a prefix if present.
      Specified by:
      remove in interface PrefixMap<V>
      Parameters:
      prefix - prefix whose mapping is to be removed from the prefixmap
      Returns:
      the previous value associated with prefix (may be null).
    • get

      public V get(String prefix)
      Description copied from interface: PrefixMap
      Return the value of the exact matching prefix.

      The value returned is the stored prefix for which is true: input.equals(prefix) .

      Specified by:
      get in interface PrefixMap<V>
      Parameters:
      prefix - The string for which we need value of the stored prefix
      Returns:
      The value, null if not found.
    • getShortestMatch

      public V getShortestMatch(PrimitiveIterator.OfInt input)
      Description copied from interface: PrefixMap
      Return the value of the shortest matching prefix.

      The value returned is the shortest stored prefix for which is true: input.startsWith(prefix).

      Specified by:
      getShortestMatch in interface PrefixMap<V>
      Parameters:
      input - The string (iterator of Unicode CodePoints) for which we need value of the stored prefix.
      Returns:
      The value, null if not found.
    • getLongestMatch

      public V getLongestMatch(PrimitiveIterator.OfInt input)
      Description copied from interface: PrefixMap
      Return the value of the longest matching prefix.

      The value returned is the longest stored prefix for which is true: input.startsWith(prefix).

      Specified by:
      getLongestMatch in interface PrefixMap<V>
      Parameters:
      input - The string (iterator of Unicode CodePoints) for which we need value of the stored prefix.
      Returns:
      The value, null if not found.
    • getAllMatches

      public Iterator<V> getAllMatches(PrimitiveIterator.OfInt input)
      Description copied from interface: PrefixMap
      Returns List of all matches that have a value.

      The list contains all non-null values for the prefix values where this is true: input.startsWith(prefix).

      Specified by:
      getAllMatches in interface PrefixMap<V>
      Parameters:
      input - The string (iterator of Unicode CodePoints) for which we need value of the stored prefix.
      Returns:
      The list of values, an empty List if nothing is found.
    • entrySet

      public Set<Map.Entry<String,V>> entrySet()
      Specified by:
      entrySet in interface Map<String,V>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,V>
      Specified by:
      containsKey in interface PrefixMap<V>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,V>
      Specified by:
      containsValue in interface PrefixMap<V>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,V>
      Specified by:
      keySet in interface PrefixMap<V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<String,V>
      Specified by:
      values in interface PrefixMap<V>
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface Map<String,V>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,V>
      Overrides:
      hashCode in class Object