Top Description Fields Constructors Methods
org.pcollections

public Class OrderedPMap<K, V>

extends AbstractUnmodifiableMap<K, V>
implements PMap<K, V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.pcollections.PMap, java.util.Map
Imports
java.io.Serializable, java.util.Collection, .Iterator, .LinkedHashMap, .Map, .Objects, .Set

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 java.lang.Comparable#compareTo(Object) or java.util.Comparator#compare(Object, Object).)

Field Summary

Modifier and TypeField and Description
private static final OrderedPMap<Object, Object>
private final PSortedMap<Long, Map.Entry<K, V>>
private final PMap<K, Long>
private static final long

Constructor Summary

AccessConstructor and Description
private
OrderedPMap(final PMap<K, Long> ids, final PSortedMap<Long, Map.Entry<K, V>> entries)

Method Summary

Modifier and TypeMethod and Description
public static <K, V> OrderedPMap<K, V>
public Set<Map.Entry<K, V>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

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

public V
get(final Object
the key whose associated value is to be returned
k
)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

public OrderedPMap<K, V>
public OrderedPMap<K, V>
public OrderedPMap<K, V>
plus(final K k, final V v)

Implements org.pcollections.PMap.plus.

public OrderedPMap<K, V>
plusAll(final Map<? extends K, ? extends V> map)

Implements org.pcollections.PMap.plusAll.

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

public int
size()

Overrides java.util.AbstractMap.size.

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.

Inherited from org.pcollections.AbstractUnmodifiableMap:
clearcomputecomputeIfAbsentcomputeIfPresentmergeputputAllputIfAbsentremovereplacereplaceAll

Field Detail

EMPTYback to summary
private static final OrderedPMap<Object, Object> EMPTY
entriesback to summary
private final PSortedMap<Long, Map.Entry<K, V>> entries
idsback to summary
private final PMap<K, Long> ids
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

OrderedPMapback to summary
private OrderedPMap(final PMap<K, Long> ids, final PSortedMap<Long, Map.Entry<K, V>> entries)

Method Detail

emptyback to summary
public static <K, V> OrderedPMap<K, V> empty()
Annotations
@SuppressWarnings:unchecked
entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<K, V>>

a set view of the mappings contained in this map

Annotations
@Override
fromback to summary
public static <K, V> OrderedPMap<K, V> from(final Map<? extends K, ? extends V> map)
Annotations
@SuppressWarnings:unchecked
getback to summary
public V get(final Object k)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
k:Object

the key whose associated value is to be returned

Returns:V

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
minusback to summary
public OrderedPMap<K, V> minus(final Object k)

Implements org.pcollections.PMap.minus.

Returns:OrderedPMap<K, V>

Doc from org.pcollections.PMap.minus.

a map with the mappings of this but with no value for key

Annotations
@Override
minusAllback to summary
public OrderedPMap<K, V> minusAll(final Collection<?> keys)

Implements org.pcollections.PMap.minusAll.

Returns:OrderedPMap<K, V>

Doc from org.pcollections.PMap.minusAll.

a map with the mappings of this but with no value for any element of keys

Annotations
@Override
plusback to summary
public OrderedPMap<K, V> plus(final K k, final V v)

Implements org.pcollections.PMap.plus.

Returns:OrderedPMap<K, V>

Doc from org.pcollections.PMap.plus.

a map with the mappings of this but with key mapped to value

Annotations
@Override
plusAllback to summary
public OrderedPMap<K, V> plusAll(final Map<? extends K, ? extends V> map)

Implements org.pcollections.PMap.plusAll.

Returns:OrderedPMap<K, V>

Doc from org.pcollections.PMap.plusAll.

this combined with map, with map's mappings used for any keys in both map and this

Annotations
@Override
singletonback to summary
public static <K, V> OrderedPMap<K, V> singleton(final K k, final V v)
sizeback to summary
public int size()

Overrides java.util.AbstractMap.size.

Implements java.util.Map.size.

Doc from java.util.Map.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of key-value mappings in this map

Annotations
@Override