27template <
typename T1,
typename T2>
31 bimap(
const T1 tbl1[],
const T2 tbl2[],
int n);
35 const T2
operator[] (
const T1 key) {
return fT1Map[key]; }
37 const T1
operator[] (
const T2 key) {
return fT2Map[key]; }
39 long size() {
return fT1Map.size(); }
43 { fT1Map[v1]=v2; fT2Map[v2]=v1;
return *
this; }
50template <
typename T1,
typename T2>
53 for (
int i=0; i<n; i++) {
54 add(tbl1[i], tbl2[i]);
61template <
typename T1,
typename T2>
67 typedef typename pairmap<T1,T2>::iterator iterator;
68 typedef typename pairmap<T1,T2>::const_iterator const_iterator;
70 iterator insert (
const pair<T1,T2>& x)
71 {
return exist (x) ? this->end() : multimap<T1,T2>::insert(x); }
72 iterator insert (iterator position,
const pair<T1,T2>& x)
73 {
return exist (x) ? this->end() : multimap<T1,T2>::insert(position, x); }
77 bool exist (
const pair<T1,T2>& x)
const {
78 for (const_iterator i=find(x.first); (i!=this->end()) && (i->first==x.first); i++)
79 if (i->second == x.second)
return true;
implements a bijective map
Definition: bimap.h:28
const T2 operator[](const T1 key)
returns the second type value indexed by the first type
Definition: bimap.h:35
long size()
returns the map size
Definition: bimap.h:39
bimap & add(const T1 &v1, const T2 &v2)
adds a pair of values
Definition: bimap.h:42
implements a multimap where <key, value> pairs are unique
Definition: bimap.h:62