Classes | Public Member Functions

threadsafe_multimap< K, T > Class Template Reference
[Threadsafe Collection API]

A very simple map object that is safe for multiple threads to use at the same time. More...

#include <threadsafe_multimap.h>

Collaboration diagram for threadsafe_multimap< K, T >:
Collaboration graph
[legend]

List of all members.

Classes

class  iterator_t

Public Member Functions

int size (void)
 how many elements in the map
int count (IN const K &key)
 how many elements with the given key
void insert (IN const K &key, IN const T &t)
 insert the given object at the given key value
void remove (IN const K &key)
 remove (erase) all elements with this key
void clear (void)
 clear out (erase) the entire map
void getIterator (OUT iterator_t &i)
 get an iterator (points to the first element in the map)
void getIterator (IN const K &key, OUT iterator_t &i)
 get an iterator just for a particular key
bool getNextElement (IO iterator_t &i, OUT K &k, OUT T &t)
 get next element in map and increment iterator
T * getNextElementUnsafe (IO iterator_t &i, OUT K &k)
 get next element without getting a local copy.

Detailed Description

template<class K, class T>
class threadsafe_multimap< K, T >

A very simple map object that is safe for multiple threads to use at the same time.

There is a single mutex protecting the entire map.

You can iterate using getIterator()/getNextElement(). However, that is not guaranteed iteration. Your iterator will be invalidated (and getNextElement() will return false) if another thread has since updated the map.

Definition at line 56 of file threadsafe_multimap.h.


Member Function Documentation

template<class K, class T>
int threadsafe_multimap< K, T >::size ( void   )  [inline]

how many elements in the map

Definition at line 77 of file threadsafe_multimap.h.

template<class K, class T>
int threadsafe_multimap< K, T >::count ( IN const K &  key  )  [inline]

how many elements with the given key

Definition at line 84 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::insert ( IN const K &  key,
IN const T &  t 
) [inline]

insert the given object at the given key value

Reimplemented in Datahash.

Definition at line 90 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::remove ( IN const K &  key  )  [inline]

remove (erase) all elements with this key

Definition at line 97 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::clear ( void   )  [inline]

clear out (erase) the entire map

Definition at line 105 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::getIterator ( OUT iterator_t i  )  [inline]

get an iterator (points to the first element in the map)

Definition at line 112 of file threadsafe_multimap.h.

template<class K, class T>
void threadsafe_multimap< K, T >::getIterator ( IN const K &  key,
OUT iterator_t i 
) [inline]

get an iterator just for a particular key

Definition at line 120 of file threadsafe_multimap.h.

template<class K, class T>
bool threadsafe_multimap< K, T >::getNextElement ( IO iterator_t i,
OUT K &  k,
OUT T &  t 
) [inline]

get next element in map and increment iterator

Definition at line 129 of file threadsafe_multimap.h.

template<class K, class T>
T* threadsafe_multimap< K, T >::getNextElementUnsafe ( IO iterator_t i,
OUT K &  k 
) [inline]

get next element without getting a local copy.

Caller had better be sure that the element won't be removed after this call!

Definition at line 141 of file threadsafe_multimap.h.


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