Lines Matching refs:set

42 #include "set.h"
120 _mesa_set_init(struct set *ht, void *mem_ctx,
140 struct set *
146 struct set *ht;
148 ht = ralloc(mem_ctx, struct set);
174 struct set *
180 struct set *
181 _mesa_set_clone(struct set *set, void *dst_mem_ctx)
183 struct set *clone;
185 clone = ralloc(dst_mem_ctx, struct set);
189 memcpy(clone, set, sizeof(struct set));
197 memcpy(clone->table, set->table, clone->size * sizeof(struct set_entry));
203 * Frees the given set.
209 _mesa_set_destroy(struct set *ht, void (*delete_function)(struct set_entry *entry))
225 set_clear_fast(struct set *ht)
232 * Clears all values from the given set.
235 * the set is cleared.
238 _mesa_set_clear(struct set *set, void (*delete_function)(struct set_entry *entry))
240 if (!set)
246 for (entry = set->table; entry != set->table + set->size; entry++) {
252 set->entries = 0;
253 set->deleted_entries = 0;
255 set_clear_fast(set);
259 * Finds a set entry with the given key and hash of that key.
264 set_search(const struct set *ht, uint32_t hash, const void *key)
293 _mesa_set_search(const struct set *set, const void *key)
295 assert(set->key_hash_function);
296 return set_search(set, set->key_hash_function(key), key);
300 _mesa_set_search_pre_hashed(const struct set *set, uint32_t hash,
303 assert(set->key_hash_function == NULL ||
304 hash == set->key_hash_function(key));
305 return set_search(set, hash, key);
309 set_add_rehash(struct set *ht, uint32_t hash, const void *key)
331 set_rehash(struct set *ht, unsigned new_size_index)
333 struct set old_ht;
372 _mesa_set_resize(struct set *set, uint32_t entries)
374 /* You can't shrink a set below its number of entries */
375 if (set->entries > entries)
376 entries = set->entries;
382 set_rehash(set, size_index);
393 set_search_or_add(struct set *ht, uint32_t hash, const void *key, bool *found)
459 set_add(struct set *ht, uint32_t hash, const void *key)
480 _mesa_set_add(struct set *set, const void *key)
482 assert(set->key_hash_function);
483 return set_add(set, set->key_hash_function(key), key);
487 _mesa_set_add_pre_hashed(struct set *set, uint32_t hash, const void *key)
489 assert(set->key_hash_function == NULL ||
490 hash == set->key_hash_function(key));
491 return set_add(set, hash, key);
495 _mesa_set_search_and_add(struct set *set, const void *key, bool *replaced)
497 assert(set->key_hash_function);
498 return _mesa_set_search_and_add_pre_hashed(set,
499 set->key_hash_function(key),
504 _mesa_set_search_and_add_pre_hashed(struct set *set, uint32_t hash,
507 assert(set->key_hash_function == NULL ||
508 hash == set->key_hash_function(key));
509 struct set_entry *entry = set_search_or_add(set, hash, key, replaced);
522 _mesa_set_search_or_add(struct set *set, const void *key, bool *found)
524 assert(set->key_hash_function);
525 return set_search_or_add(set, set->key_hash_function(key), key, found);
529 _mesa_set_search_or_add_pre_hashed(struct set *set, uint32_t hash,
532 assert(set->key_hash_function == NULL ||
533 hash == set->key_hash_function(key));
534 return set_search_or_add(set, hash, key, found);
544 _mesa_set_remove(struct set *ht, struct set_entry *entry)
558 _mesa_set_remove_key(struct set *set, const void *key)
560 _mesa_set_remove(set, _mesa_set_search(set, key));
564 * This function is an iterator over the set when no deleted entries are present.
569 _mesa_set_next_entry_unsafe(const struct set *ht, struct set_entry *entry)
591 _mesa_set_next_entry(const struct set *ht, struct set_entry *entry)
608 _mesa_set_random_entry(struct set *ht,
635 * Helper to create a set with pointer keys.
637 struct set *
645 _mesa_set_intersects(struct set *a, struct set *b)
650 /* iterate over the set with less entries */
652 struct set *tmp = a;