Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

adapter_map Class Template Reference

#include <coherence/stl/adapter_map.hpp>

Inherited by boxing_map.

List of all members.


Detailed Description

template<class K, class V>
class coherence::stl::adapter_map< K, V >

adapter_map provides an STL-like "pair associative container" wrapper around coherence::util::Map implementations.

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.

See also:
boxing_map

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_typeoperator= (const this_type &that)
 Reassign this adapter_map to reference the same Map as another adapter_map.
this_typeoperator= (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
 
Returns:
the number of the key-value std::pairs in the map
size_type max_size () const
 
Returns:
size() of the largest possible map
bool empty () const
 
Returns:
true only iff this map is empty
const_iterator cbegin () const
 
Returns:
a const_iterator referring to the first element in the container; if the map is empty, then
const_iterator begin () const
 
Returns:
a const_iterator referring to the first element in the container; if the map is empty, then
iterator begin ()
 
Returns:
an iterator referring to the first element in the container; if the map is empty, then
const_iterator cend () const
 
Returns:
a const_iterator which is the past-the-end value for the container; if the map is empty, then
const_iterator end () const
 
Returns:
a const_iterator which is the past-the-end value for the container; if the map is empty, then
iterator end ()
 
Returns:
an iterator which is the past-the-end value for the container; if the map is empty, then
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)
 
Returns:
an iterator pointing to an element with the key equal to k, or this->end() if such an element is not found.
const_iterator find (const key_type &k) const
 
Returns:
an iterator pointing to an element with the key equal to k, or this->end() if such an element is not found.
size_type count (const key_type &k) const
 
Returns:
the number of element with key equal to k (0 or 1).
std::pair< iterator,
iterator
equal_range (const key_type &k)
 
Returns:
a std::pair of iterators which locate the element with key k.
std::pair
< const_iterator,
const_iterator
equal_range (const key_type &k) const
 
Returns:
a std::pair of iterators which locate the element with key k.
allocator_type get_allocator () const
 
Returns:
a copy of the Allocator object
hasher hash_function () const
 
Returns:
hash function
key_equal key_eq () const
 
Returns:
key equality predicate

Protected Attributes

MemberHolder< Mapm_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...

Member Typedef Documentation

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.


Constructor & Destructor Documentation

adapter_map ( Map::Holder  ohMap = NULL  )  [inline]

Create new adapter_map from the given Coherence Map.

Parameters:
 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.


Member Function Documentation

Map::Handle delegate (  )  [inline]

Return the coherence::util::Map to which this adapter_map delegates.

Returns:
the associated coherence::util::Map::Handle
Exceptions:
 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.

Returns:
the associated coherence::util::Map::View

const_iterator cbegin (  )  const [inline]

Returns:
a const_iterator referring to the first element in the container; if the map is empty, then

 cbegin() == cend() 

const_iterator begin (  )  const [inline]

Returns:
a const_iterator referring to the first element in the container; if the map is empty, then

 begin() == end() 

iterator begin (  )  [inline]

Returns:
an iterator referring to the first element in the container; if the map is empty, then

 begin() == end() 

const_iterator cend (  )  const [inline]

Returns:
a const_iterator which is the past-the-end value for the container; if the map is empty, then

 cbegin() == cend() 

const_iterator end (  )  const [inline]

Returns:
a const_iterator which is the past-the-end value for the container; if the map is empty, then

 begin() == end() 

iterator end (  )  [inline]

Returns:
an iterator which is the past-the-end value for the container; if the map is empty, then

 begin() == end()  

adapter_map< K, V >::mapped_reference operator[] ( const key_type key  )  [inline]

Return a reference to the value mapped to the key.

Parameters:
 key a key to search in the map
Returns:
a reference to x.second, where x is the (unique) element whose key is equal to key

adapter_map< K, V >::mapped_type operator[] ( const key_type key  )  const [inline]

Return a reference to the value mapped to the key.

Parameters:
 key a key to search in the map
Returns:
a reference to x.second, where x is the (unique) element whose key is equal to key

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.

Parameters:
 x the key-value std::pair to insert into this map
Returns:
the std::pair which indicates the insertion status and points to the corresponding map entry

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.

Parameters:
 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.
Returns:
iterator pointing to the element with key equal to the key of x.

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.

Note:
it is required that first and last are not iterators into this map. Otherwise, behavior of
 insert(first, last) 
is undefined.

void erase ( iterator  position  )  [inline]

Erase an element pointed to by position.

All erase methods invalidate only iterators and references to the erased elements.

Parameters:
 position an iterator specifying the element to erase

void erase ( iterator  first,
    iterator  last 
  )    [inline]

Erase all elements in the range [first, last).

All erase methods invalidate only iterators and references to the erased elements.

size_type erase ( const key_type k  )  [inline]

Erase an element in the map with key equal to the argument.

All erase methods invalidate only iterators and references to the erased elements.

Parameters:
 k key whose mapping is to be removed from the map.
Returns:
the number of erased elements (0 or 1).

std::pair< typename adapter_map< K, V >::iterator, typename adapter_map< K, V >::iterator > equal_range ( const key_type k  )  [inline]

Returns:
a std::pair of iterators which locate the element with key k.

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]

Returns:
a std::pair of iterators which locate the element with key k.

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.


The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.