Lines Matching refs:ht
60 struct hash_table *ht; in hash_table_ctor() local
68 ht = malloc(sizeof(*ht) + ((num_buckets - 1) in hash_table_ctor()
69 * sizeof(ht->buckets[0]))); in hash_table_ctor()
70 if (ht != NULL) { in hash_table_ctor()
71 ht->hash = hash; in hash_table_ctor()
72 ht->compare = compare; in hash_table_ctor()
73 ht->num_buckets = num_buckets; in hash_table_ctor()
76 make_empty_list(& ht->buckets[i]); in hash_table_ctor()
80 return ht; in hash_table_ctor()
85 hash_table_dtor(struct hash_table *ht) in hash_table_dtor() argument
87 hash_table_clear(ht); in hash_table_dtor()
88 free(ht); in hash_table_dtor()
93 hash_table_clear(struct hash_table *ht) in hash_table_clear() argument
100 for (i = 0; i < ht->num_buckets; i++) { in hash_table_clear()
101 foreach_s(node, temp, & ht->buckets[i]) { in hash_table_clear()
106 assert(is_empty_list(& ht->buckets[i])); in hash_table_clear()
112 get_node(struct hash_table *ht, const void *key) in get_node() argument
114 const unsigned hash_value = (*ht->hash)(key); in get_node()
115 const unsigned bucket = hash_value % ht->num_buckets; in get_node()
118 foreach(node, & ht->buckets[bucket]) { in get_node()
121 if ((*ht->compare)(hn->key, key) == 0) { in get_node()
130 hash_table_find(struct hash_table *ht, const void *key) in hash_table_find() argument
132 struct hash_node *hn = get_node(ht, key); in hash_table_find()
138 hash_table_insert(struct hash_table *ht, void *data, const void *key) in hash_table_insert() argument
140 const unsigned hash_value = (*ht->hash)(key); in hash_table_insert()
141 const unsigned bucket = hash_value % ht->num_buckets; in hash_table_insert()
149 insert_at_head(& ht->buckets[bucket], & node->link); in hash_table_insert()
153 hash_table_replace(struct hash_table *ht, void *data, const void *key) in hash_table_replace() argument
155 const unsigned hash_value = (*ht->hash)(key); in hash_table_replace()
156 const unsigned bucket = hash_value % ht->num_buckets; in hash_table_replace()
160 foreach(node, & ht->buckets[bucket]) { in hash_table_replace()
163 if ((*ht->compare)(hn->key, key) == 0) { in hash_table_replace()
174 insert_at_head(& ht->buckets[bucket], & hn->link); in hash_table_replace()
179 hash_table_remove(struct hash_table *ht, const void *key) in hash_table_remove() argument
181 struct node *node = (struct node *) get_node(ht, key); in hash_table_remove()
190 hash_table_call_foreach(struct hash_table *ht, in hash_table_call_foreach() argument
198 for (bucket = 0; bucket < ht->num_buckets; bucket++) { in hash_table_call_foreach()
200 foreach_s(node, temp, &ht->buckets[bucket]) { in hash_table_call_foreach()