12#ifndef HASHMAP_EXTRA_CC
13#define HASHMAP_EXTRA_CC
16#define TMPL template <class T, class U>
17#define H hashentry<T, U>
24 if (l->item.code ==
hv && l->item.key == x)
return;
27 if (size >= n *
max) resize (n << 1);
34 if (
bl->item.code ==
hv &&
bl->item.key == x) {
35 rl->item.im=
bl->item.im;
45 int i= 0, n=
patch->n;
48 for (; !
is_nil (l); l= l->next) {
50 U y=
contains (x) ? bracket_ro (x) : l->item.im;
51 if (
base[x] == y) reset (x);
52 else bracket_rw (x)= y;
59 int i= 0, n=
patch->n;
62 for (; !
is_nil (l); l= l->next) {
65 if (
base[x] == y) reset (x);
66 else bracket_rw (x)= y;
85 for (i= 0; i < n; i++)
94 for (i= 0; i <
patch->n; i++) {
97 if (l->item.im !=
base[l->item.key]) h (l->item.key)= l->item.im;
108 for (i= 0; i <
patch->n; i++) {
111 if (l->item.im !=
base[l->item.key]) h (l->item.key)=
base[l->item.key];
int hash(pointer ptr)
Computes a hash value for a pointer.
void write_back(T x, hashmap< T, U > base)
Writes back a key-value pair into the current hashmap using a base hashmap as a reference.
void post_patch(hashmap< T, U > patch, hashmap< T, U > base)
Applies a post-patch to the current hashmap using another hashmap as a base reference.
void pre_patch(hashmap< T, U > patch, hashmap< T, U > base)
Applies a patch to the current hashmap using another hashmap as a base reference.
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.
bool is_nil(list< T > l)
Check if a list is nil (i.e., an empty list).
bool contains(list< T > l, T what)
Check if a list contains a specific item.
SI max(SI i, SI j)
Returns the maximum of two signed integers.