modified: diffout.py
[GalaxyCodeBases.git] / c_cpp / lib / uthash / doc / index.html
blobe3d8504bb731c0b8ede1ad594ee9adefd6fa90f0
1 <!DOCTYPE html
2 PUBLIC "-//W3C//DTD XTHML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6 <link rel="stylesheet" type="text/css" href="styles.css" />
7 <title>uthash: a hash table for C structures</title>
8 </head>
9 <body>
11 <div id="banner">
12 <img src="banner.png" alt="uthash: a hash table for C structures" />
13 </div> <!-- banner -->
15 <div id="topnav">
16 <a href="http://github.com/troydhanson/uthash">GitHub page</a> &gt;
17 uthash home <!-- http://troydhanson.github.com/uthash/ -->
19 <a href="https://twitter.com/share" class="twitter-share-button" data-via="troydhanson">Tweet</a>
20 <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
21 </div>
23 <hr />
24 <div id="mid">
26 <div id="nav">
28 <h2>documentation</h2>
29 <div><a href="userguide.html">uthash</a></div>
30 <div><a href="utlist.html">utlist</a></div>
31 <div><a href="utarray.html">utarray</a></div>
32 <div><a href="utringbuffer.html">utringbuffer</a></div>
33 <div><a href="utstring.html">utstring</a></div>
35 <h2>download</h2>
36 <h3>GNU/Linux, Windows</h3>
37 <div><a href=https://github.com/troydhanson/uthash/archive/master.zip>uthash-master.zip</a></div>
38 <div><a href=https://github.com/troydhanson/uthash>git clone</a></div>
40 <h2>license</h2>
41 <div><a href="license.html">BSD revised</a></div>
44 <h2>developer</h2>
45 <div><a href="http://troydhanson.github.io/">Troy D. Hanson</a></div>
47 <h2>maintainer</h2>
48 <div><a href="https://github.com/Quuxplusone">Arthur O'Dwyer</a></div>
51 </div>
53 <div id="main">
54 Any C structure can be stored in a hash table using uthash. Just add a
55 <em>UT_hash_handle</em> to the structure and choose one or more fields
56 in your structure to act as the key. Then use these macros to store,
57 retrieve or delete items from the hash table.
59 <div class="listing">
60 Example 1. Adding an item to a hash.
61 <div class="code">
62 <pre>
63 #include "uthash.h"
65 struct my_struct {
66 int id; /* we'll use this field as the key */
67 char name[10];
68 UT_hash_handle hh; /* makes this structure hashable */
71 struct my_struct *users = NULL;
73 void add_user(struct my_struct *s) {
74 HASH_ADD_INT( users, id, s );
77 </pre>
78 </div> <!-- code -->
79 </div> <!-- listing -->
81 <div class="listing">
82 Example 2. Looking up an item in a hash.
83 <div class="code">
84 <pre>
85 struct my_struct *find_user(int user_id) {
86 struct my_struct *s;
88 HASH_FIND_INT( users, &amp;user_id, s );
89 return s;
92 </pre>
93 </div> <!-- code -->
94 </div> <!-- listing -->
96 <div class="listing">
97 Example 3. Deleting an item from a hash.
98 <div class="code">
100 <pre>
101 void delete_user(struct my_struct *user) {
102 HASH_DEL( users, user);
105 </pre>
106 </div> <!-- code -->
107 </div> <!-- listing -->
109 For more information and examples, please see the <a href="userguide.html">User Guide.</a>
111 </div> <!-- main -->
112 </div> <!-- mid -->
114 <hr />
115 <div id="footer">
116 </div> <!-- footer -->
118 </body>
120 </html>