Lines Matching defs:key
60 * The hash table needs a particular pointer to be the marker for a key that
63 * and we use a 1:1 mapping from GLuints to key pointers, so we need to be
64 * able to track a GLuint that happens to match the deleted key outside of
65 * struct hash_table. We tell the hash table to use "1" as the deleted key
66 * value, so that we test the deleted-key-in-the-table path as best we can.
125 key_pointer_is_reserved(const struct hash_table *ht, const void *key)
127 return key == NULL || key == ht->deleted_key;
133 return entry->key == NULL;
139 return entry->key == ht->deleted_key;
145 return entry->key != NULL && entry->key != ht->deleted_key;
151 uint32_t (*key_hash_function)(const void *key),
173 uint32_t (*key_hash_function)(const void *key),
195 key_u32_hash(const void *key)
197 uint32_t u = (uint32_t)(uintptr_t)key;
207 /* key == 0 and key == deleted_key are not allowed */
284 entry->key = NULL;
292 /** Sets the value of the key pointer used for deleted entries in the table.
309 hash_table_search(struct hash_table *ht, uint32_t hash, const void *key)
311 assert(!key_pointer_is_reserved(ht, key));
325 if (ht->key_equals_function(key, entry->key)) {
339 * Finds a hash table entry with the given key and hash of that key.
345 _mesa_hash_table_search(struct hash_table *ht, const void *key)
348 return hash_table_search(ht, ht->key_hash_function(key), key);
353 const void *key)
355 assert(ht->key_hash_function == NULL || hash == ht->key_hash_function(key));
356 return hash_table_search(ht, hash, key);
361 const void *key, void *data);
365 const void *key, void *data)
375 if (likely(entry->key == NULL)) {
377 entry->key = key;
421 hash_table_insert_rehash(ht, entry->hash, entry->key, entry->data);
431 const void *key, void *data)
435 assert(!key_pointer_is_reserved(ht, key));
460 * with a matching key. This is a relatively common
463 * return it first when the key is searched for".
472 ht->key_equals_function(key, entry->key)) {
473 entry->key = key;
487 available_entry->key = key;
500 * Inserts the key with the given hash into the table.
506 _mesa_hash_table_insert(struct hash_table *ht, const void *key, void *data)
509 return hash_table_insert(ht, ht->key_hash_function(key), key, data);
514 const void *key, void *data)
516 assert(ht->key_hash_function == NULL || hash == ht->key_hash_function(key));
517 return hash_table_insert(ht, hash, key, data);
533 entry->key = ht->deleted_key;
539 * Removes the entry with the corresponding key, if exists.
542 const void *key)
544 _mesa_hash_table_remove(ht, _mesa_hash_table_search(ht, key));
563 return entry->key ? entry : _mesa_hash_table_next_entry_unsafe(ht, entry);
641 _mesa_hash_int(const void *key)
643 return XXH32(key, sizeof(int), 0);
647 _mesa_hash_uint(const void *key)
649 return XXH32(key, sizeof(unsigned), 0);
653 _mesa_hash_u32(const void *key)
655 return XXH32(key, 4, 0);
669 const char *key = _key;
671 hash = (uint32_t)XXH64(key, length, hash);
673 hash = XXH32(key, length, hash);
756 key_u64_hash(const void *key)
758 return _mesa_hash_data(key, sizeof(struct hash_key_u64));
802 struct hash_key_u64 *_key = (struct hash_key_u64 *)entry->key;
831 _mesa_hash_table_u64_insert(struct hash_table_u64 *ht, uint64_t key,
834 if (key == FREED_KEY_VALUE) {
839 if (key == DELETED_KEY_VALUE) {
845 _mesa_hash_table_insert(ht->table, (void *)(uintptr_t)key, data);
851 _key->value = key;
858 hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key)
861 return _mesa_hash_table_search(ht->table, (void *)(uintptr_t)key);
863 struct hash_key_u64 _key = { .value = key };
869 _mesa_hash_table_u64_search(struct hash_table_u64 *ht, uint64_t key)
873 if (key == FREED_KEY_VALUE)
876 if (key == DELETED_KEY_VALUE)
879 entry = hash_table_u64_search(ht, key);
887 _mesa_hash_table_u64_remove(struct hash_table_u64 *ht, uint64_t key)
891 if (key == FREED_KEY_VALUE) {
896 if (key == DELETED_KEY_VALUE) {
901 entry = hash_table_u64_search(ht, key);
908 struct hash_key *_key = (struct hash_key *)entry->key;