11 template <
class K,
class V>
12 inline void add(std::vector< std::pair<K,V> >& a_vec,
const K& a_key,
const V& a_value) {
13 typedef typename std::vector< std::pair<K,V> >::iterator it_t;
15 for(it=a_vec.begin();it!=a_vec.end();++it) {
16 if((*it).first==a_key) {
17 (*it).second = a_value;
22 a_vec.push_back(std::pair<K,V>(a_key,a_value));
25 template <
class K,
class V>
26 inline bool find(
const std::vector< std::pair<K,V> >& a_vec,
const K& a_key,V& a_value) {
27 typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
29 for(it=a_vec.begin();it!=a_vec.end();++it) {
30 if((*it).first==a_key) {
31 a_value = (*it).second;
39 template <
class K,
class V>
40 inline bool rfind(
const std::vector< std::pair<K,V> >& a_vec,
const K& a_key,V& a_value) {
41 typedef typename std::vector< std::pair<K,V> >::const_reverse_iterator it_t;
43 for(it=a_vec.rbegin();it!=a_vec.rend();++it) {
44 if((*it).first==a_key) {
45 a_value = (*it).second;
53 template <
class K,
class V>
54 inline bool is_key(
const std::vector< std::pair<K,V> >& a_vec,
const K& a_key) {
55 typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
57 for(it=a_vec.begin();it!=a_vec.end();++it) {
58 if((*it).first==a_key)
return true;
63 template <
class K,
class V>
64 inline bool find_key(
const std::vector< std::pair<K,V> >& a_vec,
const V& a_value,K& a_key) {
65 typedef typename std::vector< std::pair<K,V> >::const_iterator it_t;
67 for(it=a_vec.begin();it!=a_vec.end();++it) {
68 if((*it).second==a_value) {
77 template <
class K,
class V>
82 std::vector< std::pair<K,V> > v;
83 typedef typename std::vector< std::pair<K,V> >::iterator it_t;
86 for(it=a_vec.begin();it!=a_vec.end();++it) {
87 const V& val = (*it).second;
91 for(it2=v.begin();it2!=v.end();++it2) {
92 if(val<(*it2).second) {
106 template <
class K,
class V>
107 inline bool remove(std::vector< std::pair<K,V> >& a_vec,
const K& a_key) {
108 typedef typename std::vector< std::pair<K,V> >::iterator it_t;
110 for(it=a_vec.begin();it!=a_vec.end();++it) {
111 if((*it).first==a_key) {
119 template <
class K,
class V>
120 inline bool remove(std::vector< std::pair<K,V> >& a_vec,
const K& a_key,
bool a_delete) {
121 typedef typename std::vector< std::pair<K,V> >::iterator it_t;
123 for(it=a_vec.begin();it!=a_vec.end();++it) {
124 if((*it).first==a_key) {
125 V val = (*it).second;
127 if(a_delete)
delete val;