Package com.groiss.ds

Class OrderedMap<K,V>

java.lang.Object
com.groiss.ds.OrderedMap<K,V>
All Implemented Interfaces:
Cloneable, Map<K,V>

public class OrderedMap<K,V> extends Object implements Map<K,V>, Cloneable
A map implementation where they keys are backed by a hashmap. Removal of keys is disallowed. Duplicate keys are disallowed at construction time. Changing a value for a key is allowed. Additional keys are allowed. All clones of an instance share the same keys.
  • Constructor Details

    • OrderedMap

      public OrderedMap(List<K> keyList)
      Create a new OrderedList.
      Parameters:
      keyList - a list of keys for the map; duplicates are disallowed.
  • Method Details

    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
    • containsKey

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

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<K,V>
    • entrySet

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

      public int getPosition(K key)
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • get

      public V get(Object key)
      Specified by:
      get in interface Map<K,V>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<K,V>
    • keySet

      public Set<K> keySet()
      Specified by:
      keySet in interface Map<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
    • putAll

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
    • size

      public int size()
      Specified by:
      size in interface Map<K,V>
    • values

      public Collection<V> values()
      Specified by:
      values in interface Map<K,V>
    • getValueList

      public List<V> getValueList()
    • toString

      public String toString()
      Overrides:
      toString in class Object