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"; }
108 const V &
val(
const K &rkey,
bool m=0)
const;
110 V &
val(
const K &rkey,
bool m=0);
116 const V &
val_def(
const K &rkey,
const V &def)
const;
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);
145 const int present(
const K &rkey)
const;
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; }
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; }
192 K &points_at(
const IPointer_k &ip) {
return list(ip.p).k; }
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
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
EST_TList< EST_TKVI< K, V > > list
Linked list of key-val pairs. Don't use this as it will be made private in the future.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
const int present(const K &rkey) const
Returns true if key is present.
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.
int change_val(const K &rkey, const V &rval)
int change_key(EST_Litem *ptr, const K &rkey)
change name of key pair.
static V * default_val
default value, returned when there is no such entry.
static K * default_key
default value, returned when there is no such entry.
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.
const V & val_def(const K &rkey, const V &def) const
value or default