util/set: Use fast modulo computation
[mesa.git] / src / util / set.h
index 307a2e46765a7ba92bbd29ac683881ca58b5aca3..55857aca7ab4a4f9ac899eb4114af12ae2bef7e8 100644 (file)
@@ -47,6 +47,8 @@ struct set {
    bool (*key_equals_function)(const void *a, const void *b);
    uint32_t size;
    uint32_t rehash;
+   uint64_t size_magic;
+   uint64_t rehash_magic;
    uint32_t max_entries;
    uint32_t size_index;
    uint32_t entries;
@@ -65,6 +67,8 @@ void
 _mesa_set_destroy(struct set *set,
                   void (*delete_function)(struct set_entry *entry));
 void
+_mesa_set_resize(struct set *set, uint32_t entries);
+void
 _mesa_set_clear(struct set *set,
                 void (*delete_function)(struct set_entry *entry));
 
@@ -73,12 +77,24 @@ _mesa_set_add(struct set *set, const void *key);
 struct set_entry *
 _mesa_set_add_pre_hashed(struct set *set, uint32_t hash, const void *key);
 
+struct set_entry *
+_mesa_set_search_or_add(struct set *set, const void *key);
+struct set_entry *
+_mesa_set_search_or_add_pre_hashed(struct set *set, uint32_t hash,
+                                   const void *key);
+
 struct set_entry *
 _mesa_set_search(const struct set *set, const void *key);
 struct set_entry *
 _mesa_set_search_pre_hashed(const struct set *set, uint32_t hash,
                             const void *key);
 
+struct set_entry *
+_mesa_set_search_and_add(struct set *set, const void *key, bool *replaced);
+struct set_entry *
+_mesa_set_search_and_add_pre_hashed(struct set *set, uint32_t hash,
+                                    const void *key, bool *replaced);
+
 void
 _mesa_set_remove(struct set *set, struct set_entry *entry);
 void