16#define TMPL template <class T, class U>
17#define H hashentry<T, U>
29 out << h.key <<
"->" << h.im;
35 return (
h1.code ==
h2.code) && (
h1.key ==
h2.key) && (
h1.im ==
h2.im);
40 return (
h1.code !=
h2.code) || (
h1.key !=
h2.key) || (
h1.im !=
h2.im);
54 for (i= 0; i <
oldn; i++) {
70 if (l->item.code ==
hv && l->item.key == x)
return true;
86 if (l->item.code ==
hv && l->item.key == x)
return l->item.im;
89 if (size >= n *
max) resize (n << 1);
101 if (l->item.code ==
hv && l->item.key == x)
return l->item.im;
112 if ((*l)->item.code ==
hv && (*l)->item.key == x) {
115 if (size < (n >> 1) *
max) resize (n >> 1);
125 for (i= 0; i < n; i++) {
136 int i= 0,
j= 0, n= h->n, size= h->size;
140 for (; !
is_nil (l); l= l->next,
j++) {
142 if (
j != size - 1) out <<
", ";
154 for (; !
is_nil (l); l= l->next)
155 bracket_rw (l->item.key)=
copy (l->item.im);
161 if (
h1->size !=
h2->size)
return false;
165 for (; !
is_nil (l); l= l->next)
166 if (
h2[l->item.key] != l->item.im)
return false;
int hash(pointer ptr)
Computes a hash value for a pointer.
void resize(int n)
Resizes the hashmap and rehashes all existing keys.
void reset(T x)
Remove a specific key from the hashmap, if it exists.
void generate(void(*routine)(T))
Applies a given routine to each key in the hashmap.
void join(hashmap< T, U > H)
Joins another hashmap into the current hashmap.
The list class represents a linked list.
list(T item)
Construct a new list object with a single item.
static list< T > init
A static list object used for initializing new list objects.
void tm_delete_array(C *Ptr)
bool operator==(H h1, H h2)
tm_ostream & operator<<(tm_ostream &out, H h)
bool operator!=(H h1, H h2)
bool is_nil(list< T > l)
Check if a list is nil (i.e., an empty list).
list< T > copy(list< T > l)
Create a copy of a list.
SI max(SI i, SI j)
Returns the maximum of two signed integers.