Class OrderedPMap<K,V>

Type Parameters:
K -
V -
All Implemented Interfaces:
Serializable, Map<K,V>, PMap<K,V>

public class OrderedPMap<K,V> extends AbstractUnmodifiableMap<K,V> implements PMap<K,V>, Serializable
Like PMap but preserves insertion order. Persistent equivalent of LinkedHashMap.

Note that, like LinkedHashMap, insertion order is not affected if a key is re-inserted into the map.

(Note: this is different from PSortedMap, which keeps elements in the order specified by Comparable.compareTo(Object) or Comparator.compare(Object, Object).)

See Also:
  • Method Details

    • empty

      public static <K, V> OrderedPMap<K,V> empty()
    • from

      public static <K, V> OrderedPMap<K,V> from(Map<? extends K,? extends V> map)
    • singleton

      public static <K, V> OrderedPMap<K,V> singleton(K k, V v)
    • get

      public V get(Object k)
      Specified by:
      get in interface Map<K,V>
      Overrides:
      get in class AbstractMap<K,V>
    • plus

      public OrderedPMap<K,V> plus(K k, V v)
      Specified by:
      plus in interface PMap<K,V>
      Returns:
      a map with the mappings of this but with key mapped to value
    • plusAll

      public OrderedPMap<K,V> plusAll(Map<? extends K,? extends V> map)
      Specified by:
      plusAll in interface PMap<K,V>
      Returns:
      this combined with map, with map's mappings used for any keys in both map and this
    • minus

      public OrderedPMap<K,V> minus(Object k)
      Specified by:
      minus in interface PMap<K,V>
      Returns:
      a map with the mappings of this but with no value for key
    • minusAll

      public OrderedPMap<K,V> minusAll(Collection<?> keys)
      Specified by:
      minusAll in interface PMap<K,V>
      Returns:
      a map with the mappings of this but with no value for any element of keys
    • entrySet

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

      public int size()
      Specified by:
      size in interface Map<K,V>
      Overrides:
      size in class AbstractMap<K,V>