std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc > Class Template Reference

expanded map template class More...

#include <map2.h>

Inheritance diagram for std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >:

Inheritance graph
{mbo::CStrMap\< std::basic_string, __Ty, std::deque2\< std::basic_string \>, __CTy, __Pr, __Alloc \>\n||+ ~CStrMap()\l}{mbo::CStrMap\< std::basic_string \>\n||+ ~CStrMap()\l}{std::map2\< std::basic_string, __Ty, std::deque2\< std::basic_string \>, __CTy, __Pr, __Alloc \>\n||+ operator[]()\l+ keys()\l+ keys()\l+ values()\l+ values()\l+ insert_elem()\l+ select()\l+ contains_key()\l+ first_key()\l+ first_elem()\l+ first_elem()\l}{std::map2\< std::basic_string, std::basic_string\< Char \>, std::deque2\< std::basic_string \>, std::deque2\< std::basic_string\< Char \> \>, mbo::less_ic\< std::basic_string \>, std::allocator\< std::pair\< std::basic_string, std::basic_string \> \> \>\n||+ operator[]()\l+ keys()\l+ keys()\l+ values()\l+ values()\l+ insert_elem()\l+ select()\l+ contains_key()\l+ first_key()\l+ first_elem()\l+ first_elem()\l}{mbo::CStrMapStr\< std::basic_string \>\n||+ ~CStrMapStr()\l+ CStrMapStr()\l+ CStrMapStr()\l+ ToCStr()\l+ Scan()\l}
[legend]
Collaboration diagram for std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef __Kty_container _Kty_container
typedef __Ty_container _Ty_container
typedef map2< __Kty, __Ty,
_Kty_container, _Ty_container,
__Pr, __Alloc > 
_Myt
typedef map< __Kty, __Ty, __Pr,
__Alloc > 
_Mybase
typedef pair< const __Kty, __Ty > _Element
typedef __Kty _Kty
typedef __Ty _Ty
typedef check_fun_t< _Myt,
_Element
_Element_check_fun_t
typedef check_fun_t
< _Kty_container, __Kty > 
_Kty_check_fun_t
typedef check_fun_t
< _Ty_container, __Ty > 
_Ty_check_fun_t

Public Member Functions

_Tyoperator[] (const _Kty &key)
_Kty_container keys () const
_Kty_container keys (_Kty_check_fun_t check) const
_Ty_container values () const
_Ty_container values (_Ty_check_fun_t check) const
pair< iterator, bool > insert_elem (const _Kty &key, const _Ty &val)
_Myt select (_Element_check_fun_t check) const
bool contains_key (const _Kty &key) const
const _Ktyfirst_key (const _Kty &if_empty) const
_Tyfirst_elem (_Ty &if_empty)
const _Tyfirst_elem (const _Ty &if_empty) const


Detailed Description

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
class std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >

expanded map template class

The template map2 is derived from std::map and uses list2, vector2 or deque2 as key and value containers with vector2 being the default since that should normally result in faster applications.

The main advantage of this specialisation is that you are able to retrieve a container for all or selected keys and/or values. The container type used for this task is determined by the container types used when constructing a class from this template.

This specialisation supports:

Parameters:
_Kty key type
_Ty value type
_Kty_container container for keys (vector2, list2, deque2)
_Ty_container container for values (vector2, list2, deque2)
_Pr less prediction
_Alloc element allocator

Definition at line 149 of file map2.h.


Member Typedef Documentation

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef __Kty_container std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Kty_container

type abbrevation for Key container

Definition at line 153 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef __Ty_container std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Ty_container

type abbrevation for Value container

Definition at line 154 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef map2<__Kty, __Ty, _Kty_container, _Ty_container, __Pr, __Alloc> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Myt

type abbreveation for this class

Definition at line 155 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef map<__Kty, __Ty, __Pr, __Alloc> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Mybase

type abbrevation for parent class/template

Definition at line 156 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef pair<const __Kty, __Ty> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Element

type abbrevation for element type

Definition at line 157 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef __Kty std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Kty

type abbrevation for Key type

Definition at line 158 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef __Ty std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Ty

type abbrevation for Value type

Definition at line 159 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef check_fun_t<_Myt,_Element> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Element_check_fun_t

type abbrevation for Element check function

Definition at line 160 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef check_fun_t<_Kty_container,__Kty> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Kty_check_fun_t

tape abbrevation for Key check function

Definition at line 161 of file map2.h.

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
typedef check_fun_t<_Ty_container,__Ty> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::_Ty_check_fun_t

tape abbrevation for Value check function

Definition at line 162 of file map2.h.


Member Function Documentation

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Ty& std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::operator[] ( const _Kty key  )  [inline]

Definition at line 166 of file map2.h.

00167     {
00168         iterator it = insert_elem(key, _Ty()).first;
00169         return (*it).second;
00170     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Kty_container std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::keys (  )  const [inline]

Returns std::deque, std::list or std::vector of all keys stored in this map.

This is dependent on the template parameter _Kty_containter that defaults to deque2.

Note:
if you want to assign the function result to an instance of an equivalent class type it may be necessary to specify the correct type for _Kty_container in the template parameter list.
See also:
keys(_IN _Kty_check_fun_t check)

std::check_fun

Returns:
key container

Definition at line 187 of file map2.h.

00188     {
00189         _Kty_container __container;
00190         for (const_iterator it=begin(); it!=end(); ++it)
00191         {
00192             __container.push_back(it->first);
00193         }
00194         return __container;
00195     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Kty_container std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::keys ( _Kty_check_fun_t  check  )  const [inline]

Returns std::deque, std::list or std::vector of selected keys stored in this map.

This is dependent on the template parameter _Kty_containter that defaults to std::deque2.

With this specialized version you are able to decide which keys of the map should make it in the returned container.

For example this makes it easy to build a list of keys that conform to to a certain condition. such like returning all keys that start with the same string when using strings as keys.

See also:
keys()

std::check_fun

Parameters:
check key selection helper function
Returns:
key container

Definition at line 216 of file map2.h.

00217     {
00218         _Kty_container container;
00219         for (const_iterator it=begin(); it!=end(); ++it)
00220         {
00221             if (check(container, it->first))
00222             {
00223                 container.push_back(it->first);
00224             }
00225         }
00226         return container;
00227     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Ty_container std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::values (  )  const [inline]

Returns std::deque, std::list or std::vector of all elements stored in this map.

This is dependent on the template parameter _Ty_containter that defaults to std::deque2.

Note:
if you want to assign the function result to an instance of an equivalent class type it may be necessary to specify the correct type for _Ty_container in the template parameter list.
See also:
values(_IN _Ty_check_fun_t check)

std::check_fun

Returns:
element container

Definition at line 244 of file map2.h.

00245     {
00246         _Ty_container container;
00247         for (const_iterator it=begin(); it!=end(); ++it)
00248         {
00249             container.push_back(it->second);
00250         }
00251         return container;
00252     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Ty_container std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::values ( _Ty_check_fun_t  check  )  const [inline]

Returns std::deque, std::list, std::vector of selected elements stored in this map.

This is dependent on the template parameter _Ty_containter that defaults to std::deque2.

With this specialized version you are able to decide which elements of the map should make it in the returned container.

For example this makes building a container of unique elements easy when the container is deque2, list2 or vector2.

	  std::map2<int, char*, std::deque2<int>, std::deque2<char*> > v;
	  std::deque2<char*> unique = v.values(std::check_fun(std::deque2<char*>::contains_no));
	 

In the above example the check_fun helper adapter is used to turn the function std::deque2::contains_no into the required test function. This way every element of v is passed to unique.contains_no().

See also:
values()

std::check_fun

Parameters:
check element selection helper function
Returns:
element container

Definition at line 281 of file map2.h.

00282     {
00283         _Ty_container container;
00284         for (const_iterator it=begin(); it!=end(); ++it)
00285         {
00286             if (check(container, it->second))
00287             {
00288                 container.push_back(it->second);
00289             }
00290         }
00291         return container;
00292     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
pair<iterator, bool> std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::insert_elem ( const _Kty key,
const _Ty val 
) [inline]

Insert a pair constructed from explicit key and val parameters. This is different from operator[] since it uses insert and does therefor not change an existing pair. There exists a template mem function insert what means that all insert functions are non virtual and therefore we cannot name this function insert.

Parameters:
key Key of element to insert
val Value of element to insert
Returns:
  • iterator iterator to element if inserted or to end()
  • bool whether or not the element was inserted

Definition at line 307 of file map2.h.

Referenced by std::map2< std::basic_string, std::basic_string< Char >, std::deque2< std::basic_string >, std::deque2< std::basic_string< Char > >, mbo::less_ic< std::basic_string >, std::allocator< std::pair< std::basic_string, std::basic_string > > >::operator[]().

00308     {
00309         return /*_Mybase::*/insert(make_pair(key, val));
00310     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Myt std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::select ( _Element_check_fun_t  check  )  const [inline]

Selectively copy key/value pairs to a new map of the same type.

See also:
std::check_fun
Parameters:
check element selection helper function

Definition at line 318 of file map2.h.

00319     {
00320         _Myt container;
00321         for (const_iterator it=begin(); it!=end(); ++it)
00322         {
00323             if (check(container, *it))
00324             {
00325                 container.insert(*it);
00326             }
00327         }
00328         return container;
00329     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
bool std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::contains_key ( const _Kty key  )  const [inline]

Check whether or not the map contains a specific key.

Parameters:
key Key of element to search for

Definition at line 335 of file map2.h.

Referenced by mbo::StrToColor().

00336     {
00337         return find(key) != end();
00338     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
const _Kty& std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::first_key ( const _Kty if_empty  )  const [inline]

Retrieves the first key or a default one if the map is empty.

Parameters:
if_empty Key to use when map is empty.
Returns:
Reference to either if_empty in case map is empty or the first key.
Note:
Since local objects are destroyed at block end you are able to to calls like const T x = y.first_key(T());.

Definition at line 349 of file map2.h.

00350     {
00351         if (size())
00352         {
00353             return begin()->first;
00354         }
00355         else
00356         {
00357             return if_empty;
00358         }
00359     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
_Ty& std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::first_elem ( _Ty if_empty  )  [inline]

Retrieves the first value or a default one if the map is empty.

Parameters:
if_empty Value to use when map is empty.
Returns:
Reference to either if_empty in case map is empty or the first value.
Note:
Since local objects are destroyed at block end you are able to to calls like T x = y.first_elem(T());.

Definition at line 370 of file map2.h.

00371     {
00372         if (size())
00373         {
00374             return begin()->second;
00375         }
00376         else
00377         {
00378             return if_empty;
00379         }
00380     }

template<class __Kty, class __Ty, class __Kty_container = std::deque2 <__Kty>, class __Ty_container = std::deque2 <__Ty>, class __Pr = less<__Kty>, class __Alloc = allocator<pair<const __Kty, __Ty> >>
const _Ty& std::map2< __Kty, __Ty, __Kty_container, __Ty_container, __Pr, __Alloc >::first_elem ( const _Ty if_empty  )  const [inline]

Retrieves the first value or a default one if the map is empty (const).

Parameters:
if_empty Value to use when map is empty.
Returns:
Reference (const) to either if_empty in case map is empty or the first value.
Note:
Since local objects are destroyed at block end you are able to to calls like const T x = y.first_elem(T());.

Definition at line 391 of file map2.h.

00392     {
00393         if (size())
00394         {
00395             return begin()->second;
00396         }
00397         else
00398         {
00399             return if_empty;
00400         }
00401     }


The documentation for this class was generated from the following file:
  Hosted on code.google.com  
© Marcus Börger
Generated on Fri Jan 18 21:21:15 2008 for MBO-lib by doxygen 1.5.4