Lines Matching refs:elm

52 #define HT_FIND(name, head, elm)     name##_HT_FIND((head), (elm))
53 #define HT_INSERT(name, head, elm) name##_HT_INSERT((head), (elm))
54 #define HT_REPLACE(name, head, elm) name##_HT_REPLACE((head), (elm))
55 #define HT_REMOVE(name, head, elm) name##_HT_REMOVE((head), (elm))
57 #define HT_NEXT(name, head, elm) name##_HT_NEXT((head), (elm))
58 #define HT_NEXT_RMV(name, head, elm) name##_HT_NEXT_RMV((head), (elm))
105 #define HT_SET_HASH_(elm, field, hashfn) \
106 do { (elm)->field.hte_hash = hashfn(elm); } while (0)
107 #define HT_SET_HASHVAL_(elm, field, val) \
108 do { (elm)->field.hte_hash = (val); } while (0)
109 #define HT_ELT_HASH_(elm, field, hashfn) \
110 ((elm)->field.hte_hash)
112 #define HT_SET_HASH_(elm, field, hashfn) \
114 #define HT_ELT_HASH_(elm, field, hashfn) \
115 (hashfn(elm))
116 #define HT_SET_HASHVAL_(elm, field, val) \
120 /* Helper: alias for the bucket containing 'elm'. */
121 #define HT_BUCKET_(head, field, elm, hashfn) \
122 ((head)->hth_table[HT_ELT_HASH_(elm,field,hashfn) % head->hth_table_length])
142 * 'head' to find or insert the element 'elm'. */ \
144 name##_HT_FIND_P_(struct name *head, struct type *elm) \
149 p = &HT_BUCKET_(head, field, elm, hashfn); \
151 if (eqfn(*p, elm)) \
157 /* Return a pointer to the element in the table 'head' matching 'elm', \
160 name##_HT_FIND(const struct name *head, struct type *elm) \
164 HT_SET_HASH_(elm, field, hashfn); \
165 p = name##_HT_FIND_P_(h, elm); \
168 /* Insert the element 'elm' into the table 'head'. Do not call this \
171 name##_HT_INSERT(struct name *head, struct type *elm) \
177 HT_SET_HASH_(elm, field, hashfn); \
178 p = &HT_BUCKET_(head, field, elm, hashfn); \
179 elm->field.hte_next = *p; \
180 *p = elm; \
182 /* Insert the element 'elm' into the table 'head'. If there already \
186 name##_HT_REPLACE(struct name *head, struct type *elm) \
191 HT_SET_HASH_(elm, field, hashfn); \
192 p = name##_HT_FIND_P_(head, elm); \
194 *p = elm; \
195 if (r && (r!=elm)) { \
196 elm->field.hte_next = r->field.hte_next; \
204 /* Remove any element matching 'elm' from the table 'head'. If such \
207 name##_HT_REMOVE(struct name *head, struct type *elm) \
210 HT_SET_HASH_(elm, field, hashfn); \
211 p = name##_HT_FIND_P_(head,elm); \
261 /* Return the next element in 'head' after 'elm', under the arbitrary \
263 * NULL. If 'elm' is to be removed from the table, you must call \
267 name##_HT_NEXT(struct name *head, struct type **elm) \
269 if ((*elm)->field.hte_next) { \
270 return &(*elm)->field.hte_next; \
272 unsigned b = (HT_ELT_HASH_(*elm, field, hashfn) % head->hth_table_length)+1; \
282 name##_HT_NEXT_RMV(struct name *head, struct type **elm) \
284 unsigned h = HT_ELT_HASH_(*elm, field, hashfn); \
285 *elm = (*elm)->field.hte_next; \
287 if (*elm) { \
288 return elm; \
336 struct type *elm, *next; \
338 elm = head->hth_table[b]; \
339 while (elm) { \
340 next = elm->field.hte_next; \
341 b2 = HT_ELT_HASH_(elm, field, hashfn) % new_len; \
342 elm->field.hte_next = new_table[b2]; \
343 new_table[b2] = elm; \
344 elm = next; \
391 struct type *elm; \
409 for (elm = head->hth_table[i]; elm; elm = elm->field.hte_next) { \
410 if (HT_ELT_HASH_(elm, field, hashfn) != hashfn(elm)) \
412 if ((HT_ELT_HASH_(elm, field, hashfn) % head->hth_table_length) != i) \
425 #define HT_FIND_OR_INSERT_(name, field, hashfn, head, eltype, elm, var, y, n) \
432 HT_SET_HASH_((elm), field, hashfn); \
433 var = name##_HT_FIND_P_(var##_head_, (elm)); \
440 #define HT_FOI_INSERT_(field, head, elm, newent, var) \
442 HT_SET_HASHVAL_(newent, field, (elm)->field.hte_hash); \