Class OrderedPMap<K,​V>

  • Type Parameters:
    K -
    V -
    All Implemented Interfaces:
    java.io.Serializable, java.util.Map<K,​V>, PMap<K,​V>

    public class OrderedPMap<K,​V>
    extends AbstractUnmodifiableMap<K,​V>
    implements PMap<K,​V>, java.io.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:
    Serialized Form
    • 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>
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private OrderedPMap​(PMap<K,​java.lang.Long> ids, PSortedMap<java.lang.Long,​java.util.Map.Entry<K,​V>> entries)  
    • Field Detail

      • EMPTY

        private static final OrderedPMap<java.lang.Object,​java.lang.Object> EMPTY
      • ids

        private final PMap<K,​java.lang.Long> ids
      • entries

        private final PSortedMap<java.lang.Long,​java.util.Map.Entry<K,​V>> entries
    • Constructor Detail

      • OrderedPMap

        private OrderedPMap​(PMap<K,​java.lang.Long> ids,
                            PSortedMap<java.lang.Long,​java.util.Map.Entry<K,​V>> entries)
    • Method Detail

      • empty

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

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

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

        public V get​(java.lang.Object k)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get in class java.util.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​(java.util.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​(java.lang.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​(java.util.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 java.util.Set<java.util.Map.Entry<K,​V>> entrySet()
        Specified by:
        entrySet in interface java.util.Map<K,​V>
        Specified by:
        entrySet in class java.util.AbstractMap<K,​V>
      • size

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