The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
multimapwithdefault< Key, T, Compare > Class Template Reference

#include <multimapwdef.h>

+ Inheritance diagram for multimapwithdefault< Key, T, Compare >:
+ Collaboration diagram for multimapwithdefault< Key, T, Compare >:

Public Types

typedef std::pair< const Key, T > value_type
 

Public Member Functions

T & getWithDefault (const Key &k, const T &defaultValue)
 
bool has (const Key &k, const T &val) const
 
T & operator[] (const Key &k)
 

Public Attributes

elements
 STL member. More...
 
keys
 STL member. More...
 

Detailed Description

template<class Key, class T, class Compare>
class multimapwithdefault< Key, T, Compare >

Definition at line 36 of file multimapwdef.h.

Member Typedef Documentation

template<class Key , class T , class Compare >
typedef std::pair<const Key, T> multimapwithdefault< Key, T, Compare >::value_type

Definition at line 38 of file multimapwdef.h.

Member Function Documentation

template<class Key , class T , class Compare >
T& multimapwithdefault< Key, T, Compare >::getWithDefault ( const Key &  k,
const T &  defaultValue 
)
inline

Definition at line 39 of file multimapwdef.h.

39  {
40  if (find(k) == this->end()) {
41  insert(value_type(k, defaultValue));
42  }
43  return (*(find(k))).second;
44  }
std::pair< const Key, T > value_type
Definition: multimapwdef.h:38
template<class Key , class T , class Compare >
bool multimapwithdefault< Key, T, Compare >::has ( const Key &  k,
const T &  val 
) const
inline

Definition at line 52 of file multimapwdef.h.

52  {
53  typename std::multimap<Key, T, Compare>::const_iterator start = this->lower_bound(k);
54  typename std::multimap<Key, T, Compare>::const_iterator end = this->upper_bound(k);
55  for (; start!=end; start++) {
56  if (start->second == val)
57  return true;
58  }
59  return false;
60  }
template<class Key , class T , class Compare >
T& multimapwithdefault< Key, T, Compare >::operator[] ( const Key &  k)
inline

Definition at line 46 of file multimapwdef.h.

46  {
47  if (this->find(k) == this->end()) {
48  this->insert(value_type(k, T()));
49  }
50  return (*(this->find(k))).second;
51  }
std::pair< const Key, T > value_type
Definition: multimapwdef.h:38

Member Data Documentation

T std::multimap< K, T >::elements
inherited

STL member.

K std::multimap< K, T >::keys
inherited

STL member.


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