39 #ifndef __EST_TKVL_H__
40 #define __EST_TKVL_H__
47 #include "instantiate/EST_TKVLI.h"
48 #include "EST_TIterator.h"
63 return( (i.k == k) && (i.v == v) );
66 friend ostream& operator << (ostream& s, EST_TKVI<K,V>
const &i)
67 {
return s << i.k <<
"\t" << i.v <<
"\n"; }
77 EST_Litem *find_pair_key(
const K &key)
const;
78 EST_Litem *find_pair_val(
const V &val)
const;
99 const int length()
const {
return list.length();}
111 const V &val(
const K &rkey,
bool m=0)
const;
113 V &val(
const K &rkey,
bool m=0);
115 const V &val(
EST_Litem *ptr,
bool m=0)
const;
119 const V &val_def(
const K &rkey,
const V &def)
const;
122 const K &key(
EST_Litem *ptr,
int m=1)
const;
127 const K &key(
const V &v,
int m=1)
const;
132 int change_val(
const K &rkey,
const V &rval);
135 int change_val(
EST_Litem *ptr,
const V &rval);
137 int change_key(
EST_Litem *ptr,
const K &rkey);
140 int add_item(
const K &rkey,
const V &rval,
int no_search = 0);
143 int remove_item(
const K &rkey,
int quiet = 0);
148 const int present(
const K &rkey)
const;
151 void map(
void (*func)(K&, V&));
153 friend ostream& operator << (ostream& s, EST_TKVL<K,V>
const &l)
155 for (p = l.list.head(); p ; p = p->next())
156 s << l.list(p).k <<
"\t" << l.list(p).v << endl;
172 void point_to_first(
IPointer &ip)
const { ip.p = list.head(); }
173 void move_pointer_forwards(IPointer &ip)
const { ip.p = ip.p->next(); }
174 bool points_to_something(
const IPointer &ip)
const {
return ip.p != NULL; }
175 EST_TKVI<K, V> &points_at(
const IPointer &ip) {
return list(ip.p); }
192 void point_to_first(
IPointer_k &ip)
const { ip.p = list.head(); }
193 void move_pointer_forwards(IPointer_k &ip)
const { ip.p = ip.p->next(); }
194 bool points_to_something(
const IPointer_k &ip)
const {
return ip.p != NULL; }
195 K &points_at(
const IPointer_k &ip) {
return list(ip.p).k; }
static K * default_key
default value, returned when there is no such entry.
EST_TKVL()
default constructor
Templated Key-Value Item. Serves as the items in the list of the EST_TKVL class.
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.
EST_Litem * head() const
Return First key value pair in list.
Templated Key-Value list. Objects of type EST_TKVL contain lists which are accessed by a key of type ...
const int length() const
number of key value pairs in list
static V * default_val
default value, returned when there is no such entry.