Package com.hazelcast.map
Interface BaseMap<K,V>
- Type Parameters:
K
- KeyV
- Value
- All Superinterfaces:
DistributedObject
- All Known Subinterfaces:
IMap<K,
V>
Base interface for Hazelcast distributed maps.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(Object key) Returnstrue
if this map contains an entry for the specified key.void
Removes the mapping for a key from this map if it is present.Returns the value for the specified key, ornull
if this map does not contain this key.boolean
isEmpty()
Returnstrue
if this map contains no entries.keySet()
Returns a set clone of the keys contained in this map.Queries the map based on the specified predicate and returns the keys of matching entries.Associates the specified value with the specified key in this map.Associates the specified value with the specified key in this map with a given ttl (time to live) value.putIfAbsent
(K key, V value) If the specified key is not already associated with a value, associate it with the given value.Removes the mapping for a key from this map if it is present.boolean
Removes the entry for a key only if currently mapped to a given value.Replaces the entry for a key only if it is currently mapped to some value.boolean
Replaces the entry for a key only if currently mapped to a given value.void
Associates the specified value with the specified key in this map.int
size()
Returns the number of entries in this map.values()
Returns a collection clone of the values contained in this map.Queries the map based on the specified predicate and returns the values of matching entries.Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getName, getPartitionKey, getServiceName
-
Method Details
-
containsKey
Returnstrue
if this map contains an entry for the specified key.- Parameters:
key
- The specified key.- Returns:
true
if this map contains an entry for the specified key.
-
get
Returns the value for the specified key, ornull
if this map does not contain this key.- Parameters:
key
- The specified key.- Returns:
- The value for the specified key.
-
put
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.- Parameters:
key
- The specified key.value
- The value to associate with the key.- Returns:
- Previous value associated with
key
ornull
if there was no mapping forkey
.
-
put
Associates the specified value with the specified key in this map with a given ttl (time to live) value. Entry will expire and get evicted after the ttl. If ttl is 0, then the entry lives forever.- Parameters:
key
- The specified key.value
- The value to associate with the key.ttl
- maximum time for this entry to stay in the map 0 means infinite.timeunit
- time unit for the ttl- Returns:
- Previous value associated with
key
ornull
if there was no mapping forkey
.
-
set
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced by the specified value.This method is preferred to
put(Object, Object)
if the old value is not needed.- Parameters:
key
- The specified key.value
- The value to associate with the key.
-
putIfAbsent
If the specified key is not already associated with a value, associate it with the given value. This is equivalent toif (!map.containsKey(key)) return map.put(key, value); else return map.get(key);
except that the action is performed atomically.- Parameters:
key
- The specified key.value
- The value to associate with the key when there is no previous value.- Returns:
- The previous value associated with
key
, ornull
if there was no mapping forkey
.
-
replace
Replaces the entry for a key only if it is currently mapped to some value. This is equivalent toif (map.containsKey(key)) { return map.put(key, value); } else return null;
except that the action is performed atomically.- Parameters:
key
- The specified key.value
- The value to replace the previous value.- Returns:
- The previous value associated with
key
, ornull
if there was no mapping forkey
.
-
replace
Replaces the entry for a key only if currently mapped to a given value. This is equivalent toif (map.containsKey(key) && map.get(key).equals(oldValue)) { map.put(key, newValue); return true; } else return false;
except that the action is performed atomically.- Parameters:
key
- The specified key.oldValue
- Replace the key value if it is the old value.newValue
- The new value to replace the old value.- Returns:
true
if the value was replaced.
-
remove
Removes the mapping for a key from this map if it is present.The map will not contain a mapping for the specified key once the call returns.
- Parameters:
key
- Remove the mapping for this key.- Returns:
- The previous value associated with
key
, ornull
if there was no mapping forkey
.
-
delete
Removes the mapping for a key from this map if it is present.The map will not contain a mapping for the specified key once the call returns.
*
This method is preferred to
remove(Object)
if the old value is not needed.- Parameters:
key
- Remove the mapping for this key.
-
remove
Removes the entry for a key only if currently mapped to a given value. This is equivalent toif (map.containsKey(key) && map.get(key).equals(value)) { map.remove(key); return true; } else return false;
except that the action is performed atomically.- Parameters:
key
- The specified key.value
- Remove the key if it has this value.- Returns:
true
if the value was removed.
-
isEmpty
boolean isEmpty()Returnstrue
if this map contains no entries.- Returns:
true
if this map contains no entries.
-
size
int size()Returns the number of entries in this map.- Returns:
- the number of entries in this map.
-
keySet
Returns a set clone of the keys contained in this map.- Returns:
- a set clone of the keys contained in this map.
-
keySet
Queries the map based on the specified predicate and returns the keys of matching entries.- Parameters:
predicate
- specified query criteria.- Returns:
- result key set of the query.
- Throws:
NullPointerException
- if the specified predicate is null.
-
values
Collection<V> values()Returns a collection clone of the values contained in this map.- Returns:
- a collection clone of the values contained in this map
-
values
Queries the map based on the specified predicate and returns the values of matching entries.- Parameters:
predicate
- specified query criteria.- Returns:
- result value collection of the query.
- Throws:
NullPointerException
- if the predicate is null
-