com.hazelcast.core
Interface BaseMap<K,V>

Type Parameters:
K - Key
V - Value
All Superinterfaces:
DistributedObject
All Known Subinterfaces:
IMap<K,V>, TransactionalMap<K,V>
All Known Implementing Classes:
ClientMapProxy, ClientTxnMapProxy, MapProxyImpl, TransactionalMapProxy

public interface BaseMap<K,V>
extends DistributedObject

Base interface for Hazelcast distributed maps.

See Also:
IMap, TransactionalMap

Method Summary
 boolean containsKey(Object key)
          Returns true if this map contains an entry for the specified key.
 void delete(Object key)
          Removes the mapping for a key from this map if it is present.
 V get(Object key)
          Returns the value for the specified key, or null if this map does not contain this key.
 boolean isEmpty()
          Returns true if this map contains no entries.
 V put(K key, V value)
          Associates the specified value with the specified key in this map.
 V putIfAbsent(K key, V value)
          If the specified key is not already associated with a value, associate it with the given value.
 V remove(Object key)
          Removes the mapping for a key from this map if it is present.
 boolean remove(Object key, Object value)
          Removes the entry for a key only if currently mapped to a given value.
 V replace(K key, V value)
          Replaces the entry for a key only if it is currently mapped to some value.
 boolean replace(K key, V oldValue, V newValue)
          Replaces the entry for a key only if currently mapped to a given value.
 void set(K key, V value)
          Associates the specified value with the specified key in this map.
 int size()
          Returns the number of entries in this map.
 
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getId, getName, getPartitionKey, getServiceName
 

Method Detail

containsKey

boolean containsKey(Object key)
Returns true 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

V get(Object key)
Returns the value for the specified key, or null if this map does not contain this key.

Parameters:
key - The specified key.
Returns:
The value for the specified key.

put

V put(K key,
      V value)
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 or null if there was no mapping for key.

set

void set(K key,
         V value)
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

V putIfAbsent(K key,
              V value)
If the specified key is not already associated with a value, associate it with the given value. This is equivalent to
   if (!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, or null if there was no mapping for key.

replace

V replace(K key,
          V value)
Replaces the entry for a key only if it is currently mapped to some value. This is equivalent to
   if (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, or null if there was no mapping for key.

replace

boolean replace(K key,
                V oldValue,
                V newValue)
Replaces the entry for a key only if currently mapped to a given value. This is equivalent to
   if (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

V remove(Object key)
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, or null if there was no mapping for key.

delete

void delete(Object key)
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

boolean remove(Object key,
               Object value)
Removes the entry for a key only if currently mapped to a given value. This is equivalent to
   if (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()
Returns true 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.


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.