Macaulay2 Engine
Loading...
Searching...
No Matches

◆ Table_put()

void * Table_put ( T * table,
const void * key,
void * value )

Definition at line 83 of file table.c.

84{
85 int i;
86 struct binding *p;
87 void *prev;
88 assert(table);
89 assert(key);
90 i = (*table->hash)(key) % table->size;
91 for (p = table->buckets[i]; p; p = p->link)
92 if ((*table->cmp)(key, p->key) == 0) break;
93 if (p == NULL)
94 {
95 NEW(p);
96 p->key = key;
97 p->link = table->buckets[i];
98 table->buckets[i] = p;
99 table->length++;
100 prev = NULL;
101 }
102 else
103 prev = p->value;
104 p->value = value;
105 table->timestamp++;
106 return prev;
107}
int p
int size
Definition table.c:30
unsigned timestamp
Definition table.c:34
int length
Definition table.c:33
unsigned(* hash)(const void *key)
Definition table.c:32
int(* cmp)(const void *x, const void *y)
Definition table.c:31
struct T::binding ** buckets
#define NEW(p)
Definition table.c:10

References T::buckets, T::cmp, T::hash, T::length, NEW, p, T::size, T, and T::timestamp.

Referenced by exponent_table_put().