public class DefaultConsistentTreeMap<V> extends Synchronous<AsyncConsistentTreeMap<V>> implements ConsistentTreeMap<V>
ConsistentTreeMap interface.DistributedPrimitive.Status, DistributedPrimitive.TypeDEFAULT_OPERATION_TIMEOUT_MILLIS, DEFAULT_OPERTATION_TIMEOUT_MILLIS| Constructor and Description |
|---|
DefaultConsistentTreeMap(AsyncConsistentTreeMap<V> treeMap,
long operationTimeoutMillis) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(MapEventListener<String,V> listener,
Executor executor)
Registers the specified listener to be notified whenever the map is updated.
|
Map<String,V> |
asJavaMap()
Returns a java.util.Map instance backed by this ConsistentMap.
|
Map.Entry<String,Versioned<V>> |
ceilingEntry(String key)
Returns the entry associated with the least key greater than or equal to the key.
|
String |
ceilingKey(String key)
Returns the lowest key greater than or equal to key.
|
void |
clear()
Removes all of the mappings from this map (optional operation).
|
Versioned<V> |
compute(String key,
BiFunction<? super String,? super V,? extends V> remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value (or
null if there is no current mapping).
|
Versioned<V> |
computeIf(String key,
Predicate<? super V> condition,
BiFunction<? super String,? super V,? extends V> remappingFunction)
If the value for the specified key satisfies a condition, attempts to compute a new
mapping given the key and its current mapped value.
|
Versioned<V> |
computeIfAbsent(String key,
Function<? super String,? extends V> mappingFunction)
If the specified key is not already associated with a value (or is mapped to null),
attempts to compute its value using the given mapping function and enters it into
this map unless null.
|
Versioned<V> |
computeIfPresent(String key,
BiFunction<? super String,? super V,? extends V> remappingFunction)
If the value for the specified key is present and non-null, attempts to compute a new
mapping given the key and its current mapped value.
|
boolean |
containsKey(String key)
Returns true if this map contains a mapping for the specified key.
|
boolean |
containsValue(V value)
Returns true if this map contains the specified value.
|
Set<Map.Entry<String,Versioned<V>>> |
entrySet()
Returns the set of entries contained in this map.
|
Map.Entry<String,Versioned<V>> |
firstEntry()
Returns the entry associated with the lowest key in the map.
|
String |
firstKey()
Returns the lowest key in the map.
|
Map.Entry<String,Versioned<V>> |
floorEntry(String key)
Returns the entry associated with the greatest key less than or equal to key.
|
String |
floorKey(String key)
Returns the entry associated with the highest key less than or equal to key.
|
Versioned<V> |
get(String key)
Returns the value (and version) to which the specified key is mapped, or null if this
map contains no mapping for the key.
|
Versioned<V> |
getOrDefault(String key,
V defaultValue)
Returns the value (and version) to which the specified key is mapped, or the provided
default value if this map contains no mapping for the key.
|
Map.Entry<String,Versioned<V>> |
higherEntry(String key)
Returns the entry associated with the lest key greater than key.
|
String |
higherKey(String key)
Returns the lowest key greater than key.
|
boolean |
isEmpty()
Returns true if the map is empty.
|
Iterator<Map.Entry<String,Versioned<V>>> |
iterator() |
Set<String> |
keySet()
Returns a Set view of the keys contained in this map.
|
Map.Entry<String,Versioned<V>> |
lastEntry()
Returns the entry associated with the highest key in the map.
|
String |
lastKey()
Returns the highest key in the map.
|
Map.Entry<String,Versioned<V>> |
lowerEntry(String key)
Returns the entry associated with the largest key less than key.
|
String |
lowerKey(String key)
Returns the entry associated with the greatest key less than key.
|
NavigableSet<String> |
navigableKeySet()
Returns a navigable set of the keys in this map.
|
Map.Entry<String,Versioned<V>> |
pollFirstEntry()
Returns and removes the entry associated with the lowest key.
|
Map.Entry<String,Versioned<V>> |
pollLastEntry()
Returns and removes the entry associated with the highest key.
|
Versioned<V> |
put(String key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
Versioned<V> |
putAndGet(String key,
V value)
Associates the specified value with the specified key in this map (optional operation).
|
Versioned<V> |
putIfAbsent(String key,
V value)
If the specified key is not already associated with a value
associates it with the given value and returns null, else returns the current value.
|
Versioned<V> |
remove(String key)
Removes the mapping for a key from this map if it is present (optional operation).
|
boolean |
remove(String key,
long version)
Removes the entry for the specified key only if its current
version in the map is equal to the specified version.
|
boolean |
remove(String key,
V value)
Removes the entry for the specified key only if it is currently
mapped to the specified value.
|
void |
removeListener(MapEventListener<String,V> listener)
Unregisters the specified listener such that it will no longer
receive map change notifications.
|
boolean |
replace(String key,
long oldVersion,
V newValue)
Replaces the entry for the specified key only if it is currently mapped to the
specified version.
|
Versioned<V> |
replace(String key,
V value)
Replaces the entry for the specified key only if there is any value
which associated with specified key.
|
boolean |
replace(String key,
V oldValue,
V newValue)
Replaces the entry for the specified key only if currently mapped
to the specified value.
|
int |
size()
Returns the number of entries in the map.
|
NavigableMap<String,V> |
subMap(String upperKey,
String lowerKey,
boolean inclusiveUpper,
boolean inclusiveLower)
Returns a navigable map containing the entries from the original map
which are larger than (or if specified equal to)
lowerKey AND
less than (or if specified equal to) upperKey. |
Collection<Versioned<V>> |
values()
Returns the collection of values (and associated versions) contained in this map.
|
destroy, name, primitiveTypeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, streamaddStatusChangeListener, applicationId, destroy, name, primitiveType, removeStatusChangeListener, statusChangeListenersforEach, spliteratorpublic DefaultConsistentTreeMap(AsyncConsistentTreeMap<V> treeMap, long operationTimeoutMillis)
public String firstKey()
ConsistentTreeMapfirstKey in interface ConsistentTreeMap<V>public String lastKey()
ConsistentTreeMaplastKey in interface ConsistentTreeMap<V>public Map.Entry<String,Versioned<V>> ceilingEntry(String key)
ConsistentTreeMapceilingEntry in interface ConsistentTreeMap<V>key - the keypublic Map.Entry<String,Versioned<V>> floorEntry(String key)
ConsistentTreeMapfloorEntry in interface ConsistentTreeMap<V>key - the keypublic Map.Entry<String,Versioned<V>> higherEntry(String key)
ConsistentTreeMaphigherEntry in interface ConsistentTreeMap<V>key - the keypublic Map.Entry<String,Versioned<V>> lowerEntry(String key)
ConsistentTreeMaplowerEntry in interface ConsistentTreeMap<V>key - the keypublic Map.Entry<String,Versioned<V>> firstEntry()
ConsistentTreeMapfirstEntry in interface ConsistentTreeMap<V>public Map.Entry<String,Versioned<V>> lastEntry()
ConsistentTreeMaplastEntry in interface ConsistentTreeMap<V>public Map.Entry<String,Versioned<V>> pollFirstEntry()
ConsistentTreeMappollFirstEntry in interface ConsistentTreeMap<V>public Map.Entry<String,Versioned<V>> pollLastEntry()
ConsistentTreeMappollLastEntry in interface ConsistentTreeMap<V>public String lowerKey(String key)
ConsistentTreeMaplowerKey in interface ConsistentTreeMap<V>key - the keypublic String floorKey(String key)
ConsistentTreeMapfloorKey in interface ConsistentTreeMap<V>key - the keypublic String ceilingKey(String key)
ConsistentTreeMapceilingKey in interface ConsistentTreeMap<V>key - the keypublic String higherKey(String key)
ConsistentTreeMaphigherKey in interface ConsistentTreeMap<V>key - the keypublic NavigableSet<String> navigableKeySet()
ConsistentTreeMapnavigableKeySet in interface ConsistentTreeMap<V>public int size()
ConsistentMapsize in interface ConsistentMap<String,V>public boolean isEmpty()
ConsistentMapisEmpty in interface ConsistentMap<String,V>public boolean containsKey(String key)
ConsistentMapcontainsKey in interface ConsistentMap<String,V>key - keypublic boolean containsValue(V value)
ConsistentMapcontainsValue in interface ConsistentMap<String,V>value - valuepublic Versioned<V> get(String key)
ConsistentMapget in interface ConsistentMap<String,V>key - the key whose associated value (and version) is to be returnedpublic Versioned<V> getOrDefault(String key, V defaultValue)
ConsistentMap
Note: a non-null Versioned value will be returned even if the defaultValue
is null.
getOrDefault in interface ConsistentMap<String,V>key - the key whose associated value (and version) is to be returneddefaultValue - the default value to return if the key is not setpublic Versioned<V> computeIfAbsent(String key, Function<? super String,? extends V> mappingFunction)
ConsistentMapcomputeIfAbsent in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedmappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification
if a concurrent modification of map is detectedpublic Versioned<V> compute(String key, BiFunction<? super String,? super V,? extends V> remappingFunction)
ConsistentMapcompute in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedremappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification
if a concurrent modification of map is detectedpublic Versioned<V> computeIfPresent(String key, BiFunction<? super String,? super V,? extends V> remappingFunction)
ConsistentMapcomputeIfPresent in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedremappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification
if a concurrent modification of map is detectedpublic Versioned<V> computeIf(String key, Predicate<? super V> condition, BiFunction<? super String,? super V,? extends V> remappingFunction)
ConsistentMapcomputeIf in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedcondition - condition that should evaluate to true for the computation to proceedremappingFunction - the function to compute a valueConsistentMapException.ConcurrentModification if a concurrent
modification of map is detectedpublic Versioned<V> put(String key, V value)
ConsistentMapput in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Versioned<V> putAndGet(String key, V value)
ConsistentMapputAndGet in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic Versioned<V> remove(String key)
ConsistentMapremove in interface ConsistentMap<String,V>key - key whose value is to be removed from the mappublic void clear()
ConsistentMapclear in interface ConsistentMap<String,V>public Set<String> keySet()
ConsistentMapkeySet in interface ConsistentMap<String,V>public Collection<Versioned<V>> values()
ConsistentMapvalues in interface ConsistentMap<String,V>public Set<Map.Entry<String,Versioned<V>>> entrySet()
ConsistentMapentrySet in interface ConsistentMap<String,V>public Versioned<V> putIfAbsent(String key, V value)
ConsistentMapputIfAbsent in interface ConsistentMap<String,V>key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic boolean remove(String key, V value)
ConsistentMapremove in interface ConsistentMap<String,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic boolean remove(String key, long version)
ConsistentMapremove in interface ConsistentMap<String,V>key - key with which the specified version is associatedversion - version expected to be associated with the specified keypublic Versioned<V> replace(String key, V value)
ConsistentMapreplace in interface ConsistentMap<String,V>key - key with which the specified value is associatedvalue - value expected to be associated with the specified keypublic boolean replace(String key, V oldValue, V newValue)
ConsistentMapreplace in interface ConsistentMap<String,V>key - key with which the specified value is associatedoldValue - value expected to be associated with the specified keynewValue - value to be associated with the specified keypublic boolean replace(String key, long oldVersion, V newValue)
ConsistentMapreplace in interface ConsistentMap<String,V>key - key key with which the specified value is associatedoldVersion - version expected to be associated with the specified keynewValue - value to be associated with the specified keypublic void addListener(MapEventListener<String,V> listener, Executor executor)
ConsistentMapaddListener in interface ConsistentMap<String,V>listener - listener to notify about map eventsexecutor - executor to use for handling incoming map eventspublic void removeListener(MapEventListener<String,V> listener)
ConsistentMapremoveListener in interface ConsistentMap<String,V>listener - listener to unregisterpublic Map<String,V> asJavaMap()
ConsistentMapasJavaMap in interface ConsistentMap<String,V>public NavigableMap<String,V> subMap(String upperKey, String lowerKey, boolean inclusiveUpper, boolean inclusiveLower)
ConsistentTreeMaplowerKey AND
less than (or if specified equal to) upperKey.subMap in interface ConsistentTreeMap<V>upperKey - the upper bound for the keys in this maplowerKey - the lower bound for the keys in this mapinclusiveUpper - whether keys equal to the upperKey should be
includedinclusiveLower - whether keys equal to the lowerKey should be
included