#include <coherence/stl/adapter_map.hpp>
Inherited by boxing_map.
An example usage examples may look as follows:
typedef adapter_map<String::View, Integer32::View> month_cache; month_cache months(CacheFactory::getCache("dist-months")); months["january"] = Integer32::valueOf(31); months["february"] = Integer32::valueOf(28); months["march"] = Integer32::valueOf(31); ... for (month_cache::iterator i = months.begin(), e = months.end(); i != e; ++i) { std::cout << i->first << " = " << i->second << std::endl; }
adapter_map only supports keys and values which are handles, for instance Integer32::View. See boxing_map for a variant which supports keys and values of non-managed types, including primitives.
Map
TypedCollections
Public Types | |
typedef adapter_map < K, V > | this_type |
This type. | |
typedef super::key_type | key_type |
Key type of the map. | |
typedef super::data_type | data_type |
Value type of the map. | |
typedef super::mapped_type | mapped_type |
Value type of the map. | |
typedef super::value_type | value_type |
Entry type of the map. | |
typedef super::allocator_type | allocator_type |
Allocator type for this map. | |
typedef super::difference_type | difference_type |
Signed integral type. | |
typedef super::size_type | size_type |
Unsigned integral type. | |
typedef super::iterator | iterator |
Iterator type of the forward iterator category which iterates key-value std::pairs of this map. | |
typedef super::const_iterator | const_iterator |
Const iterator type of the forward iterator category which iterates key-value std::pairs of this map. | |
typedef iterator::pointer | pointer |
Type of the values returned by iterator.operator-> . | |
typedef const_iterator::pointer | const_pointer |
Type of the values returned by const_iterator.operator-> . | |
typedef iterator::reference | reference |
Type of the values returned by iterator.operator* . | |
typedef const_iterator::reference | const_reference |
Type of the values returned by const_iterator.operator* . | |
typedef iterator::mapped_reference | mapped_reference |
Type of the values returned by adapter_map.operator[]() operator[]. | |
Public Member Functions | |
adapter_map (Map::Holder ohMap=NULL) | |
Create new adapter_map from the given Coherence Map. | |
adapter_map (const this_type &that) | |
Create a adapter_map copy. | |
virtual | ~adapter_map () |
destructor | |
this_type & | operator= (const this_type &that) |
Reassign this adapter_map to reference the same Map as another adapter_map. | |
this_type & | operator= (Map::Holder ohMap) |
Reassign this adapter_map to reference another Map. | |
Map::Handle | delegate () |
Return the coherence::util::Map to which this adapter_map delegates. | |
Map::View | delegate () const |
Return the coherence::util::Map to which this adapter_map delegates. | |
size_type | size () const |
| |
size_type | max_size () const |
| |
bool | empty () const |
| |
const_iterator | cbegin () const |
| |
const_iterator | begin () const |
| |
iterator | begin () |
| |
const_iterator | cend () const |
| |
const_iterator | end () const |
| |
iterator | end () |
| |
mapped_reference | operator[] (const key_type &key) |
Return a reference to the value mapped to the key. | |
mapped_type | operator[] (const key_type &key) const |
Return a reference to the value mapped to the key. | |
std::pair< iterator, bool > | insert (const value_type &x) |
Insert x if and only if there is no element in the map with key equal to the key of x. | |
iterator | insert (iterator hint, const value_type &x) |
Insert x if and only if there is no element in the map with key equal to the key of x. | |
template<class InputIterator> | |
void | insert (InputIterator first, InputIterator last) |
Insert each element from the range [first, last) if and only if there is no element with key equal to the key of that element in this map. | |
void | erase (iterator position) |
Erase an element pointed to by position. | |
void | erase (iterator first, iterator last) |
Erase all elements in the range [first, last) . | |
size_type | erase (const key_type &k) |
Erase an element in the map with key equal to the argument. | |
void | clear () |
Remove all elements from this map. | |
void | swap (this_type &x) |
Swap this map and argument map. | |
iterator | find (const key_type &k) |
| |
const_iterator | find (const key_type &k) const |
| |
size_type | count (const key_type &k) const |
| |
std::pair< iterator, iterator > | equal_range (const key_type &k) |
| |
std::pair < const_iterator, const_iterator > | equal_range (const key_type &k) const |
| |
allocator_type | get_allocator () const |
| |
hasher | hash_function () const |
| |
key_equal | key_eq () const |
| |
Protected Attributes | |
MemberHolder< Map > | m_ohMap |
The Coherence Map that is delegated by the adapter_map. | |
Related Functions | |
(Note that these are not member functions.) | |
template<class K, class V> | |
void | swap (adapter_map< K, V > &x, adapter_map< K, V > &y) |
Swaps two argument maps. | |
Classes | |
class | hasher |
Hasher function. More... | |
class | key_equal |
Key equality relation. More... |
typedef super::key_type key_type |
Key type of the map.
Should be handle-to-const type.
typedef super::data_type data_type |
Value type of the map.
Should be handle-to-const type.
typedef super::mapped_type mapped_type |
Value type of the map.
Should be handle-to-const type.
typedef super::value_type value_type |
Entry type of the map.
value_type is
std::pair<const key_type, mapped_type>
typedef super::allocator_type allocator_type |
Allocator type for this map.
allocator_type is
std::allocator<value_type>
typedef super::difference_type difference_type |
Signed integral type.
Identical to the difference type of iterator and const_iterator.
typedef super::size_type size_type |
Unsigned integral type.
size_type can represent any non-negative value of difference_type.
typedef super::iterator iterator |
Iterator type of the forward iterator category which iterates key-value std::pairs of this map.
Convertible to const_iterator.
adapter_map | ( | Map::Holder | ohMap = NULL |
) | [inline] |
Create new adapter_map from the given Coherence Map.
ohMap | the Map to be delegated by the adapter_map. |
adapter_map | ( | const this_type & | that | ) | [inline] |
Create a adapter_map copy.
The new adapter_map will reference the same Map, as the original adapter_map.
Map::Handle delegate | ( | ) | [inline] |
Return the coherence::util::Map to which this adapter_map delegates.
UnsupportedOperationException | if the adapater_map is delegating to a Map::View, rather then Map::Handle |
Map::View delegate | ( | ) | const [inline] |
Return the coherence::util::Map to which this adapter_map delegates.
const_iterator cbegin | ( | ) | const [inline] |
const_iterator begin | ( | ) | const [inline] |
iterator begin | ( | ) | [inline] |
const_iterator cend | ( | ) | const [inline] |
const_iterator end | ( | ) | const [inline] |
iterator end | ( | ) | [inline] |
adapter_map< K, V >::mapped_reference operator[] | ( | const key_type & | key | ) | [inline] |
Return a reference to the value mapped to the key.
key | a key to search in the map |
adapter_map< K, V >::mapped_type operator[] | ( | const key_type & | key | ) | const [inline] |
Return a reference to the value mapped to the key.
key | a key to search in the map |
std::pair< typename adapter_map< K, V >::iterator, bool > insert | ( | const value_type & | x | ) | [inline] |
Insert x if and only if there is no element in the map with key equal to the key of x.
The bool component of the returned std::pair is true if and only if the insertion takes place, and the iterator component of the std::pair points to the element with key equal to the key of argument.
All insert methods do not affect the validity of references to map elements, but may invalidate all iterators to the map.
x | the key-value std::pair to insert into this map |
iterator insert | ( | iterator | hint, | |
const value_type & | x | |||
) | [inline] |
Insert x if and only if there is no element in the map with key equal to the key of x.
All insert methods do not affect the validity of references to map elements, but may invalidate all iterators to the map.
hint | a hint pointing to where the insert should start to search. Implementation is permitted to ignore the hint. | |
x | the key-value std::pair to insert into this map. |
void insert | ( | InputIterator | first, | |
InputIterator | last | |||
) | [inline] |
Insert each element from the range [first, last) if and only if there is no element with key equal to the key of that element in this map.
All insert methods do not affect the validity of references to map elements, but may invalidate all iterators to the map.
insert(first, last)
void erase | ( | iterator | position | ) | [inline] |
Erase an element pointed to by position.
All erase methods invalidate only iterators and references to the erased elements.
position | an iterator specifying the element to erase |
Erase all elements in the range [first, last)
.
All erase methods invalidate only iterators and references to the erased elements.
Erase an element in the map with key equal to the argument.
All erase methods invalidate only iterators and references to the erased elements.
k | key whose mapping is to be removed from the map. |
std::pair< typename adapter_map< K, V >::iterator, typename adapter_map< K, V >::iterator > equal_range | ( | const key_type & | k | ) | [inline] |
If such element is found then the first component of the returned std::pair points to the element and the second component of the std::pair points to the element immediately following the found one in the iterator's traverse order. Otherwise returns a this->end(), this->;end() std::pair.
In other words, equal_range always returns the range [x, y) which contains the found element only.
std::pair< typename adapter_map< K, V >::const_iterator, typename adapter_map< K, V >::const_iterator > equal_range | ( | const key_type & | k | ) | const [inline] |
If such element is found then the first component of the returned std::pair points to the element and the second component of the std::pair points to the element immediately following the found one in the iterator's traverse order. Otherwise returns an this->end(), this->end() std::pair.
In other words, equal_range always returns the range [x, y) which contains the found element only.