Package com.helixframework.collections
Class VersionedMap<K,V>
java.lang.Object
com.helixframework.collections.VersionedMap<K,V>
- Type Parameters:
K- key typeV- value type
- All Implemented Interfaces:
Map<K,V>
Map implementation that allows for the versioning of key value pairs.
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance ofVersionedMap.VersionedMap(int maxVersions) Creates a new instance ofVersionedMapwith a cap on the maximum number of value versions stored per key.VersionedMap(Map<K, V> m) Creates a new instance ofVersionedMapand initializes it with the contents of the supplied map.VersionedMap(Map<K, V> m, int maxVersions) Creates a new instance ofVersionedMapwith a cap on the maximum number of value versions stored per key and initializes it with the contents of the supplied map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()entrySet(long ver) Returns aSetview of the mappings in this map at the specified version.Returns the value of the version of the key with the greatest version less than or equal to the given version, ornullif the key does not exist.Returns all value versions of the key.booleanisEmpty()keySet()keySet(long ver) Returns aSetof keys in this map at the specified version.voidintsize()values()values(long ver) Returns aCollectionof values in this map at the specified version.longversion()Gets the current version of the map.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
FIRST_VERSION
First version of the map.
-
-
Constructor Details
-
VersionedMap
public VersionedMap()Creates a new instance ofVersionedMap. -
VersionedMap
public VersionedMap(int maxVersions) Creates a new instance ofVersionedMapwith a cap on the maximum number of value versions stored per key. If versions of key exceed the specified amount the versions are removed in FIFO order.- Parameters:
maxVersions- maximum number of value versions to keep per key
-
VersionedMap
Creates a new instance ofVersionedMapand initializes it with the contents of the supplied map.- Parameters:
m- the map whose mappings are to be placed in this map
-
VersionedMap
Creates a new instance ofVersionedMapwith a cap on the maximum number of value versions stored per key and initializes it with the contents of the supplied map. If versions of key exceed the specified amount the versions are removed in FIFO order.- Parameters:
m- the map whose mappings are to be placed in this mapmaxVersions- maximum number of value versions to keep per key
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
get
-
get
Returns the value of the version of the key with the greatest version less than or equal to the given version, ornullif the key does not exist.- Parameters:
key- keyver- version- Returns:
- value or
nullif the key does not exist
-
getAll
Returns all value versions of the key.- Parameters:
key- key- Returns:
- all value versions or
nullif the key does not exist
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
keySet
Returns aSetof keys in this map at the specified version.- Parameters:
ver- version- Returns:
Setof keys in this map
-
values
-
values
Returns aCollectionof values in this map at the specified version.- Parameters:
ver- version- Returns:
Collectionof values in this map
-
entrySet
-
entrySet
Returns aSetview of the mappings in this map at the specified version.- Parameters:
ver- version- Returns:
Setof mappings in this map
-
version
public long version()Gets the current version of the map.Initial version of the map is `-1L`.
- Returns:
- current map version
-