Class SequentialTwoWayHashMap<K,​V>

  • Type Parameters:
    K - The key type.
    V - The value type.
    All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<K,​V>
    Direct Known Subclasses:
    MatchResult

    public class SequentialTwoWayHashMap<K,​V>
    extends TwoWayHashMap<K,​V>
    A two-way hash map where the keys are sorted. The keys are sorted in the order in which they are added to this two-way hash map.
    Since:
    Ptolemy II 8.0
    Version:
    $Id$
    Author:
    Thomas Huining Feng
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Red (tfeng)
    Pt.ProposedRating:
    Yellow (tfeng)
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear this two-way hash map.
      java.lang.Object clone()
      Clone this two-way hash map and return the clone.
      java.util.List<K> keys()
      Return a sorted list of keys.
      V put​(K key, V value)
      Put a value into this two-way hash map and associate it with a key.
      V remove​(java.lang.Object key)
      Remove the value associated with the given key.
      void removeLast()
      Remove the value associated with the last key.
      void retain​(int count)
      Retain only the first count keys and their values, and remove the other keys and values.
      • Methods inherited from class java.util.HashMap

        compute, computeIfAbsent, computeIfPresent, containsKey, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Constructor Detail

      • SequentialTwoWayHashMap

        public SequentialTwoWayHashMap()
    • Method Detail

      • clear

        public void clear()
        Clear this two-way hash map.
        Specified by:
        clear in interface java.util.Map<K,​V>
        Overrides:
        clear in class TwoWayHashMap<K,​V>
      • clone

        public java.lang.Object clone()
        Clone this two-way hash map and return the clone.
        Overrides:
        clone in class TwoWayHashMap<K,​V>
        Returns:
        The clone.
      • keys

        public java.util.List<K> keys()
        Return a sorted list of keys.
        Returns:
        The list of keys.
      • put

        public V put​(K key,
                     V value)
        Put a value into this two-way hash map and associate it with a key.
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class TwoWayHashMap<K,​V>
        Parameters:
        key - The key.
        value - The value.
        Returns:
        The value previously associated with the key in this two-way hash map.
      • remove

        public V remove​(java.lang.Object key)
        Remove the value associated with the given key.
        Specified by:
        remove in interface java.util.Map<K,​V>
        Overrides:
        remove in class TwoWayHashMap<K,​V>
        Parameters:
        key - The key.
        Returns:
        The removed value, or null if not found.
      • removeLast

        public void removeLast()
        Remove the value associated with the last key.
      • retain

        public void retain​(int count)
        Retain only the first count keys and their values, and remove the other keys and values.
        Parameters:
        count - The number of key-value pairs to be retained.