|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /proc/21573/root/usr/share/devhelp/books/dbus/api/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>D-Bus: Hash table implementation details</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
</ul></div>
<h1>Hash table implementation details<br>
<small>
[<a class="el" href="group__DBusInternals.html">D-Bus secret internal implementation details</a>]</small>
</h1><a class="el" href="structDBusHashTable.html">DBusHashTable</a> implementation details.
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct </td><td class="memItemRight" valign="bottom"><a class="el" href="structDBusHashEntry.html">DBusHashEntry</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Internal representation of a hash entry. <a href="structDBusHashEntry.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct </td><td class="memItemRight" valign="bottom"><a class="el" href="structDBusHashTable.html">DBusHashTable</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Internals of <a class="el" href="structDBusHashTable.html">DBusHashTable</a>. <a href="structDBusHashTable.html#_details">More...</a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct </td><td class="memItemRight" valign="bottom"><a class="el" href="structDBusRealHashIter.html">DBusRealHashIter</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Internals of <a class="el" href="structDBusHashIter.html">DBusHashIter</a>. <a href="structDBusRealHashIter.html#_details">More...</a><br></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="g8c6d6296d450e37074dbd8c15638b499"></a><!-- doxytag: member="DBusHashTableInternals::REBUILD_MULTIPLIER" ref="g8c6d6296d450e37074dbd8c15638b499" args="" -->
#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusHashTableInternals.html#g8c6d6296d450e37074dbd8c15638b499">REBUILD_MULTIPLIER</a> 3</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">When there are this many entries per bucket, on average, rebuild the hash table to make it larger. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusHashTableInternals.html#g9dc8fd5a9e25bd2b229366a683ff78f9">RANDOM_INDEX</a>(table, i) (((((long) (i))*1103515245) >> (table)->down_shift) & (table)->mask)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Takes a preliminary integer hash value and produces an index into a hash tables bucket list. <a href="#g9dc8fd5a9e25bd2b229366a683ff78f9"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusHashTableInternals.html#g4518324f3c3caacf5694065f4f6071d8">DBUS_SMALL_HASH_TABLE</a> 4</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Initial number of buckets in hash table (hash table statically allocates its buckets for this size and below). <a href="#g4518324f3c3caacf5694065f4f6071d8"></a><br></td></tr>
<tr><td colspan="2"><br><h2>Typedefs</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gd7d2d7c568541eeeb86104138d64a9f3"></a><!-- doxytag: member="DBusHashTableInternals::DBusHashEntry" ref="gd7d2d7c568541eeeb86104138d64a9f3" args="" -->
typedef <a class="el" href="structDBusHashEntry.html">DBusHashEntry</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusHashTableInternals.html#gd7d2d7c568541eeeb86104138d64a9f3">DBusHashEntry</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Typedef for <a class="el" href="structDBusHashEntry.html">DBusHashEntry</a>. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="gf7aa30377ff1074657bfef5e834bf931"></a><!-- doxytag: member="DBusHashTableInternals::DBusFindEntryFunction" ref="gf7aa30377ff1074657bfef5e834bf931" args="(DBusHashTable *table, void *key, dbus_bool_t create_if_not_found, DBusHashEntry ***bucket, DBusPreallocatedHash *preallocated)" -->
typedef <a class="el" href="structDBusHashEntry.html">DBusHashEntry</a> *(*) </td><td class="memItemRight" valign="bottom"><a class="el" href="group__DBusHashTableInternals.html#gf7aa30377ff1074657bfef5e834bf931">DBusFindEntryFunction</a> (<a class="el" href="structDBusHashTable.html">DBusHashTable</a> *table, void *key, <a class="el" href="group__DBusTypes.html#g39c9cb0f3a2a8ad6f55cc4855d035349">dbus_bool_t</a> create_if_not_found, <a class="el" href="structDBusHashEntry.html">DBusHashEntry</a> ***bucket, <a class="el" href="group__DBusHashTable.html#g175dc6ab841ed32bb6acf6e4c0df36a8">DBusPreallocatedHash</a> *preallocated)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Function used to find and optionally create a hash entry. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
<a class="el" href="structDBusHashTable.html">DBusHashTable</a> implementation details.
<p>
The guts of <a class="el" href="structDBusHashTable.html">DBusHashTable</a>. <hr><h2>Define Documentation</h2>
<a class="anchor" name="g4518324f3c3caacf5694065f4f6071d8"></a><!-- doxytag: member="dbus-hash.c::DBUS_SMALL_HASH_TABLE" ref="g4518324f3c3caacf5694065f4f6071d8" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define DBUS_SMALL_HASH_TABLE 4 </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Initial number of buckets in hash table (hash table statically allocates its buckets for this size and below).
<p>
The initial mask has to be synced to this.
<p>
Definition at line <a class="el" href="dbus-hash_8c-source.html#l00129">129</a> of file <a class="el" href="dbus-hash_8c-source.html">dbus-hash.c</a>.
<p>
Referenced by <a class="el" href="dbus-hash_8c-source.html#l00292">_dbus_hash_table_new()</a>.
</div>
</div><p>
<a class="anchor" name="g9dc8fd5a9e25bd2b229366a683ff78f9"></a><!-- doxytag: member="dbus-hash.c::RANDOM_INDEX" ref="g9dc8fd5a9e25bd2b229366a683ff78f9" args="(table, i)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define RANDOM_INDEX </td>
<td>(</td>
<td class="paramtype">table, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">i </td>
<td class="paramname"> </td>
<td> ) </td>
<td width="100%"> (((((long) (i))*1103515245) >> (table)->down_shift) & (table)->mask)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Takes a preliminary integer hash value and produces an index into a hash tables bucket list.
<p>
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.)<p>
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?
<p>
Definition at line <a class="el" href="dbus-hash_8c-source.html#l00121">121</a> of file <a class="el" href="dbus-hash_8c-source.html">dbus-hash.c</a>.
</div>
</div><p>
<hr size="1"><address style="align: right;"><small>Generated on Mon Dec 14 22:26:13 2009 for D-Bus by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>