47#include "instantiate/EST_TKVLI.h"
48#include "EST_TIterator.h"
61 return( (i.k == k) && (i.v == v) );
64 friend ostream& operator << (ostream& s,
EST_TKVI<K,V> const &i)
65 {
return s << i.k <<
"\t" << i.v <<
"\n"; }
74 EST_Litem *find_pair_key(
const K &
key)
const;
75 EST_Litem *find_pair_val(
const V &
val)
const;
99 EST_Litem *
head()
const {
return list.head();};
108 const V &
val(
const K &rkey,
bool m=0)
const;
110 V &
val(
const K &rkey,
bool m=0);
112 const V &
val(EST_Litem *ptr,
bool m=0)
const;
114 V &
val(EST_Litem *ptr,
bool m=0);
116 const V &
val_def(
const K &rkey,
const V &def)
const;
119 const K &
key(EST_Litem *ptr,
int m=1)
const;
121 K &
key(EST_Litem *ptr,
int m=1);
124 const K &
key(
const V &v,
int m=1)
const;
137 int add_item(
const K &rkey,
const V &rval,
int no_search = 0);
148 void map(
void (*func)(K&, V&));
150 friend ostream& operator << (ostream& s,
EST_TKVL<K,V> const &l)
152 for (p = l.
list.head(); p ; p = p->next())
153 s << l.
list(p).k <<
"\t" << l.
list(p).v << endl;
169 void point_to_first(
IPointer &ip)
const { ip.p =
list.head(); }
170 void move_pointer_forwards(
IPointer &ip)
const { ip.p = ip.p->next(); }
171 bool points_to_something(
const IPointer &ip)
const {
return ip.p != NULL; }
172 EST_TKVI<K, V> &points_at(
const IPointer &ip) {
return list(ip.p); }
175 friend class EST_TStructIterator<
EST_TKVL<K, V>,
IPointer, EST_TKVI<K, V> >;
177 friend class EST_TRwStructIterator<
EST_TKVL<K, V>,
IPointer, EST_TKVI<K, V> >;
180 typedef EST_TKVI<K, V> Entry;
181 typedef EST_TStructIterator< EST_TKVL<K, V>,
IPointer, Entry> Entries;
182 typedef EST_TRwStructIterator< EST_TKVL<K, V>,
IPointer, Entry> RwEntries;
190 void move_pointer_forwards(
IPointer_k &ip)
const { ip.p = ip.p->next(); }
191 bool points_to_something(
const IPointer_k &ip)
const {
return ip.p != NULL; }
199 typedef EST_TIterator< EST_TKVL<K, V>,
IPointer_k, KeyEntry> KeyEntries;
200 typedef EST_TRwIterator< EST_TKVL<K, V>,
IPointer_k, KeyEntry> KeyRwEntries;
const int length() const
number of key value pairs in list
EST_TKVL()
default constructor
EST_Litem * head() const
Return First key value pair in list.
int remove_item(const K &rkey, int quiet=0)
remove key and val pair from list
V & val(EST_Litem *ptr, bool m=0)
return value according to ptr
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
EST_TList< EST_TKVI< int, EST_IList > > list
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
const V & val(EST_Litem *ptr, bool m=0) const
return value according to ptr
const int present(const K &rkey) const
Returns true if key is present.
EST_TKVL(const EST_TKVL< K, V > &kv)
copy constructor
EST_TKVL< K, V > operator+(const EST_TKVL< K, V > &kv)
make new concatenated list
const K & key(EST_Litem *ptr, int m=1) const
find key, reference by ptr
EST_TKVL< K, V > & operator+=(const EST_TKVL< K, V > &kv)
add kv after existing list.
V & val(const K &rkey, bool m=0)
return value according to key (non-const)
int change_val(const K &rkey, const V &rval)
int change_key(EST_Litem *ptr, const K &rkey)
change name of key pair.
const K & key(const V &v, int m=1) const
return first matching key, referenced by val
static EST_IList * default_val
int change_val(EST_Litem *ptr, const V &rval)
void map(void(*func)(K &, V &))
apply function to each pair
EST_TKVL< K, V > & operator=(const EST_TKVL< K, V > &kv)
full copy of KV list.
K & key(EST_Litem *ptr, int m=1)
find key, reference by ptr
const V & val_def(const K &rkey, const V &def) const
value or default