Hash table implementation details
[D-Bus secret internal implementation details]

DBusHashTable implementation details. More...

Data Structures

struct  DBusHashEntry
 Internal representation of a hash entry. More...
struct  DBusHashTable
 Internals of DBusHashTable. More...
struct  DBusRealHashIter
 Internals of DBusHashIter. More...

Defines

#define REBUILD_MULTIPLIER   3
 When there are this many entries per bucket, on average, rebuild the hash table to make it larger.
#define RANDOM_INDEX(table, i)   (((((long) (i))*1103515245) >> (table)->down_shift) & (table)->mask)
 Takes a preliminary integer hash value and produces an index into a hash tables bucket list.
#define DBUS_SMALL_HASH_TABLE   4
 Initial number of buckets in hash table (hash table statically allocates its buckets for this size and below).

Typedefs

typedef DBusHashEntry DBusHashEntry
 Typedef for DBusHashEntry.
typedef DBusHashEntry *(*) DBusFindEntryFunction (DBusHashTable *table, void *key, dbus_bool_t create_if_not_found, DBusHashEntry ***bucket, DBusPreallocatedHash *preallocated)
 Function used to find and optionally create a hash entry.

Detailed Description

DBusHashTable implementation details.

The guts of DBusHashTable.


Define Documentation

#define DBUS_SMALL_HASH_TABLE   4

Initial number of buckets in hash table (hash table statically allocates its buckets for this size and below).

The initial mask has to be synced to this.

Definition at line 129 of file dbus-hash.c.

Referenced by _dbus_hash_table_new().

#define RANDOM_INDEX ( table,
 )     (((((long) (i))*1103515245) >> (table)->down_shift) & (table)->mask)

Takes a preliminary integer hash value and produces an index into a hash tables bucket list.

The idea is to make it so that preliminary values that are arbitrarily similar will end up in different buckets. The hash function was taken from a random-number generator. (This is used to hash integers.)

The down_shift drops off the high bits of the hash index, and decreases as we increase the number of hash buckets (to keep more range in the hash index). The mask also strips high bits and strips fewer high bits as the number of hash buckets increases. I don't understand two things: why is the initial downshift 28 to keep 4 bits when the initial mask is 011 to keep 2 bits, and why do we have both a mask and a downshift?

Definition at line 121 of file dbus-hash.c.


Generated on Fri Sep 21 18:12:14 2007 for D-Bus by  doxygen 1.5.1