Lines Matching full:hash
2 /* dbus-hash.c Generic hash table utility (internal to D-Bus implementation)
8 * Hash table implementation based on generic/tclHash.c from the Tcl
78 #include "dbus-hash.h"
83 * @defgroup DBusHashTable Hash table
91 * @defgroup DBusHashTableInternals Hash table implementation details
102 * the hash table to make it larger.
107 * Takes a preliminary integer hash value and produces an index into a
108 * hash tables bucket list. The idea is to make it so that
110 * different buckets. The hash function was taken from a
111 * random-number generator. (This is used to hash integers.)
113 * The down_shift drops off the high bits of the hash index, and
114 * decreases as we increase the number of hash buckets (to keep more
115 * range in the hash index). The mask also strips high bits and strips
116 * fewer high bits as the number of hash buckets increases.
126 * Initial number of buckets in hash table (hash table statically
138 * @brief Internal representation of a hash entry.
140 * A single entry (key-value pair) in the hash table.
141 * Internal to hash table implementation.
146 * hash bucket, or #NULL for end of
149 void *key; /**< Hash key */
150 void *value; /**< Hash value */
154 * Function used to find and optionally create a hash entry.
165 * Hash table internals. Hash tables are opaque objects, they must be
173 * bucket's hash chain, or #NULL.
206 DBusMemPool *entry_pool; /**< Memory pool for hash entries */
219 DBusHashEntry *entry; /**< Current hash entry */
259 * Public opaque hash table iterator object.
265 * Public opaque hash table object.
271 * Indicates the type of a key in the hash table.
275 * Constructs a new hash table. Should be freed with
277 * allocated for the hash table, returns #NULL.
279 * @param type the type of hash key to use.
280 * @param key_free_function function to free hash keys.
281 * @param value_free_function function to free hash values.
329 _dbus_assert_not_reached ("Unknown hash table type");
341 * Increments the reference count for a hash table.
343 * @param table the hash table to add a reference to.
344 * @returns the hash table.
355 * Decrements the reference count for a hash table,
356 * freeing the hash table if the count reaches zero.
358 * @param table the hash table to remove a reference from.
413 * Removed all entries from a hash table.
415 * @param table the hash table to remove all entries from.
486 * Initializes a hash table iterator. To iterate over all entries in a
487 * hash table, use the following code (the printf assumes a hash
504 * The iterator is initialized pointing "one before" the first hash
506 * the first valid entry or returns #FALSE if the hash table is
510 * Note that it is guaranteed to be safe to remove a hash entry during
511 * iteration, but it is not safe to add a hash entry.
513 * @param table the hash table to iterate over.
535 * Move the hash iterator forward one step, to the next hash entry.
551 /* if this assertion failed someone probably added hash entries
584 * Removes the current entry from the hash table.
589 * @param iter the hash table iterator.
610 * @param iter the hash table iterator.
627 * If the hash table has a value_free_function
629 * The hash table will own the passed-in value
632 * @param iter the hash table iterator.
654 * Only works for hash tables of type #DBUS_HASH_INT.
656 * @param iter the hash table iterator.
673 * Only works for hash tables of type #DBUS_HASH_UINTPTR.
675 * @param iter the hash table iterator.
692 * Only works for hash tables of type #DBUS_HASH_STRING
693 * @param iter the hash table iterator.
709 * A low-level but efficient interface for manipulating the hash
711 * create the hash entry while only running the hash function one
720 * If the hash entry is created, its value will be initialized
727 * If create_if_not_found is #TRUE and the entry is created, the hash
730 * For a hash table of type #DBUS_HASH_INT, cast the int
733 * @param table the hash table.
734 * @param key the hash key.
737 * @returns #TRUE if the hash entry now exists (and the iterator is thus valid).
1023 _dbus_assert_not_reached ("Unknown hash table type");
1040 * Looks up the value for a given string in a hash table
1044 * @param table the hash table.
1046 * @returns the value of the hash entry.
1065 * Looks up the value for a given integer in a hash table
1069 * @param table the hash table.
1071 * @returns the value of the hash entry.
1090 * Looks up the value for a given integer in a hash table
1094 * @param table the hash table.
1096 hash entry.
1115 * Removes the hash entry for the given key. If no hash entry
1118 * @param table the hash table.
1119 * @param key the hash key.
1143 * Removes the hash entry for the given key. If no hash entry
1146 * @param table the hash table.
1147 * @param key the hash key.
1171 * Removes the hash entry for the given key. If no hash entry
1174 * @param table the hash table.
1175 * @param key the hash key.
1199 * Creates a hash entry with the given key and value.
1201 * in the hash table by reference. If an entry with the
1203 * are overwritten (and freed if the hash table has
1206 * Returns #FALSE if memory for the new hash entry
1209 * @param table the hash table.
1210 * @param key the hash entry key.
1211 * @param value the hash entry value.
1233 * Creates a hash entry with the given key and value.
1235 * in the hash table by reference. If an entry with the
1237 * are overwritten (and freed if the hash table has
1240 * Returns #FALSE if memory for the new hash entry
1243 * @param table the hash table.
1244 * @param key the hash entry key.
1245 * @param value the hash entry value.
1274 * Creates a hash entry with the given key and value.
1276 * in the hash table by reference. If an entry with the
1278 * are overwritten (and freed if the hash table has
1281 * Returns #FALSE if memory for the new hash entry
1284 * @param table the hash table.
1285 * @param key the hash entry key.
1286 * @param value the hash entry value.
1316 * hash table at a later time without allocating any memory.
1318 * @param table the hash table
1333 * in order to insert into the hash table.
1335 * @param table the hash table
1353 * Inserts a string-keyed entry into the hash table, using a
1360 * @param table the hash table
1362 * @param key the hash key
1391 * Gets the number of hash entries in a hash table.
1393 * @param table the hash table.
1408 /* If you're wondering why the hash table test takes
1457 printf ("Computing test hash keys...\n");
1463 len = sprintf (keys[i], "Hash key %d", i);
1804 _dbus_assert_not_reached ("hash entry should have existed");
1808 _dbus_assert_not_reached ("hash entry should have existed");