Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | Friends | List of all members
hazelcast::client::MultiMap< K, V > Class Template Reference

A specialized distributed map client whose keys can be associated with multiple values. More...

#include <MultiMap.h>

+ Inheritance diagram for hazelcast::client::MultiMap< K, V >:

Public Member Functions

bool put (const K &key, const V &value)
 Stores a key-value pair in the multimap. More...
 
std::vector< V > get (const K &key)
 Returns the multimap of values associated with the key. More...
 
bool remove (const K &key, const V &value)
 Removes the given key value pair from the multimap. More...
 
std::vector< V > remove (const K &key)
 Removes all the entries with the given key. More...
 
std::vector< K > keySet ()
 Returns the set of keys in the multimap. More...
 
std::vector< V > values ()
 Returns the multimap of values in the multimap. More...
 
std::vector< std::pair< K, V > > entrySet ()
 Returns the set of key-value pairs in the multimap. More...
 
bool containsKey (const K &key)
 Returns whether the multimap contains an entry with the key. More...
 
bool containsValue (const V &value)
 Returns whether the multimap contains an entry with the value. More...
 
bool containsEntry (const K &key, const V &value)
 Returns whether the multimap contains the given key-value pair. More...
 
int size ()
 Returns the number of key-value pairs in the multimap. More...
 
void clear ()
 Clears the multimap. More...
 
int valueCount (const K &key)
 Returns number of values matching to given key in the multimap. More...
 
std::string addEntryListener (EntryListener< K, V > &listener, bool includeValue)
 Adds an entry listener for this multimap. More...
 
std::string addEntryListener (EntryListener< K, V > &listener, const K &key, bool includeValue)
 Adds the specified entry listener for the specified key. More...
 
bool removeEntryListener (const std::string &registrationId)
 Removes the specified entry listener Returns silently if there is no such listener added before. More...
 
void lock (const K &key)
 Acquires the lock for the specified key. More...
 
void lock (const K &key, long leaseTimeInMillis)
 Acquires the lock for the specified key for the specified lease time. More...
 
bool isLocked (const K &key)
 Checks the lock for the specified key. More...
 
bool tryLock (const K &key)
 Tries to acquire the lock for the specified key. More...
 
bool tryLock (const K &key, long timeoutInMillis)
 Tries to acquire the lock for the specified key. More...
 
void unlock (const K &key)
 Releases the lock for the specified key. More...
 
void forceUnlock (const K &key)
 Releases the lock for the specified key regardless of the lock owner. More...
 

Friends

class HazelcastClient
 
class adaptor::RawPointerMultiMap< K, V >
 

Detailed Description

template<typename K, typename V>
class hazelcast::client::MultiMap< K, V >

A specialized distributed map client whose keys can be associated with multiple values.

See Also
IMap

Member Function Documentation

template<typename K, typename V>
std::string hazelcast::client::MultiMap< K, V >::addEntryListener ( EntryListener< K, V > &  listener,
bool  includeValue 
)
inline

Adds an entry listener for this multimap.

Listener will get notified for all multimap add/remove/update/evict events.

Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.

Warning 2: Do not make a call to hazelcast. It can cause deadlock.

Parameters
listenerentry listener
includeValuetrue if EntryEvent should contain the value.
Returns
returns registration id.
template<typename K, typename V>
std::string hazelcast::client::MultiMap< K, V >::addEntryListener ( EntryListener< K, V > &  listener,
const K &  key,
bool  includeValue 
)
inline

Adds the specified entry listener for the specified key.

The listener will get notified for all add/remove/update/evict events of the specified key only.

Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.

Warning 2: Do not make a call to hazelcast. It can cause deadlock.

Parameters
listenerentry listener
keythe key to listen
includeValuetrue if EntryEvent should contain the value.
Returns
returns registration id.
template<typename K, typename V>
void hazelcast::client::MultiMap< K, V >::clear ( )
inline

Clears the multimap.

Removes all key-value pairs.

template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::containsEntry ( const K &  key,
const V &  value 
)
inline

Returns whether the multimap contains the given key-value pair.

Parameters
keythe key whose existence is checked.
valuethe value whose existence is checked.
Returns
true if the multimap contains the key-value pair, false otherwise.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::containsKey ( const K &  key)
inline

Returns whether the multimap contains an entry with the key.

Parameters
keythe key whose existence is checked.
Returns
true if the multimap contains an entry with the key, false otherwise.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::containsValue ( const V &  value)
inline

Returns whether the multimap contains an entry with the value.

Parameters
valuethe value whose existence is checked.
Returns
true if the multimap contains an entry with the value, false otherwise.
template<typename K, typename V>
std::vector<std::pair<K, V> > hazelcast::client::MultiMap< K, V >::entrySet ( )
inline

Returns the set of key-value pairs in the multimap.

Returns
the set of key-value pairs in the multimap. Returned set might be modifiable but it has no effect on the multimap
template<typename K, typename V>
void hazelcast::client::MultiMap< K, V >::forceUnlock ( const K &  key)
inline

Releases the lock for the specified key regardless of the lock owner.

It always successfully unlocks the key, never blocks and returns immediately.

Parameters
keykey to lock.
template<typename K, typename V>
std::vector<V> hazelcast::client::MultiMap< K, V >::get ( const K &  key)
inline

Returns the multimap of values associated with the key.

Parameters
keythe key whose associated values are to be returned
Returns
the multimap of the values associated with the key.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::isLocked ( const K &  key)
inline

Checks the lock for the specified key.

If the lock is acquired then returns true, else false.

Parameters
keykey to lock to be checked.
Returns
true if lock is acquired, false otherwise.
template<typename K, typename V>
std::vector<K> hazelcast::client::MultiMap< K, V >::keySet ( )
inline

Returns the set of keys in the multimap.

Returns
the set of keys in the multimap. Returned set might be modifiable but it has no effect on the multimap
template<typename K, typename V>
void hazelcast::client::MultiMap< K, V >::lock ( const K &  key)
inline

Acquires the lock for the specified key.

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

Scope of the lock is this multimap only. Acquired lock is only for the key in this multimap.

Locks are re-entrant so if the key is locked N times then it should be unlocked N times before another thread can acquire it.

Parameters
keykey to lock.
template<typename K, typename V>
void hazelcast::client::MultiMap< K, V >::lock ( const K &  key,
long  leaseTimeInMillis 
)
inline

Acquires the lock for the specified key for the specified lease time.

After lease time, lock will be released..

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

Scope of the lock is this map only. Acquired lock is only for the key in this map.

Locks are re-entrant so if the key is locked N times then it should be unlocked N times before another thread can acquire it.

Parameters
keykey to lock.
leaseTimeInMillistime in milliseconds to wait before releasing the lock.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::put ( const K &  key,
const V &  value 
)
inline

Stores a key-value pair in the multimap.

Parameters
keythe key to be stored
valuethe value to be stored
Returns
true if size of the multimap is increased, false if the multimap already contains the key-value pair.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::remove ( const K &  key,
const V &  value 
)
inline

Removes the given key value pair from the multimap.

Parameters
key
value
Returns
true if the size of the multimap changed after the remove operation, false otherwise.
template<typename K, typename V>
std::vector<V> hazelcast::client::MultiMap< K, V >::remove ( const K &  key)
inline

Removes all the entries with the given key.

Parameters
key
Returns
the multimap of removed values associated with the given key. Returned multimap might be modifiable but it has no effect on the multimap
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::removeEntryListener ( const std::string &  registrationId)
inline

Removes the specified entry listener Returns silently if there is no such listener added before.

Parameters
registrationIdId of listener registration
Returns
true if registration is removed, false otherwise
template<typename K, typename V>
int hazelcast::client::MultiMap< K, V >::size ( )
inline

Returns the number of key-value pairs in the multimap.

Returns
the number of key-value pairs in the multimap.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::tryLock ( const K &  key)
inline

Tries to acquire the lock for the specified key.

If the lock is not available then the current thread doesn't wait and returns false immediately.

Parameters
keykey to lock.
Returns
true if lock is acquired, false otherwise.
template<typename K, typename V>
bool hazelcast::client::MultiMap< K, V >::tryLock ( const K &  key,
long  timeoutInMillis 
)
inline

Tries to acquire the lock for the specified key.

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:

  • The lock is acquired by the current thread; or
  • The specified waiting time elapses
Parameters
keyto be locked.
timeoutInMillisthe maximum time to wait for the lock
Returns
true if the lock was acquired and false if the waiting time elapsed before the lock was acquired.
template<typename K, typename V>
void hazelcast::client::MultiMap< K, V >::unlock ( const K &  key)
inline

Releases the lock for the specified key.

It never blocks and returns immediately.

Parameters
keykey to lock.
template<typename K, typename V>
int hazelcast::client::MultiMap< K, V >::valueCount ( const K &  key)
inline

Returns number of values matching to given key in the multimap.

Parameters
keythe key whose values count are to be returned
Returns
number of values matching to given key in the multimap.
template<typename K, typename V>
std::vector<V> hazelcast::client::MultiMap< K, V >::values ( )
inline

Returns the multimap of values in the multimap.

Returns
the multimap of values in the multimap. Returned multimap might be modifiable but it has no effect on the multimap

The documentation for this class was generated from the following file: