Class StackMap<K,​V>

  • Type Parameters:
    K -
    V -

    public final class StackMap<K,​V>
    extends java.lang.Object
    A stack that also provides random access lookup of values. It is backed by a Deque(array deque) and a HashMap.
    Author:
    thomas.jungblut
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  StackMap.StackMapEntry<KEY,​VALUE>
      Immutable class for a Key/Value tuple.
    • Constructor Summary

      Constructors 
      Constructor Description
      StackMap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V get​(K key)
      HashMap access to get the value for a key.
      java.util.Map.Entry<K,​V> peek()
      Retrieves the first item in the stack, but does not remove it.
      java.util.Map.Entry<K,​V> pop()
      Retrieves the first item in the stack and removes it.
      V put​(K key, V value)
      Put method which puts the k/v mapping into the map and pushes the key on the stack.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StackMap

        public StackMap()
    • Method Detail

      • get

        public V get​(K key)
        HashMap access to get the value for a key.
      • put

        public V put​(K key,
                     V value)
        Put method which puts the k/v mapping into the map and pushes the key on the stack.
      • peek

        public java.util.Map.Entry<K,​V> peek()
        Retrieves the first item in the stack, but does not remove it.
      • pop

        public java.util.Map.Entry<K,​V> pop()
        Retrieves the first item in the stack and removes it.