Annotation of libwww/Library/src/HTHash.html, revision 1.3

1.1       frystyk     1: <HTML>
                      2: <HEAD>
                      3:   <TITLE>W3C Sample Code Library libwww Hash Table Class</TITLE>
                      4: </HEAD>
                      5: <BODY>
                      6: <H1>
                      7:   Hash Table Class
                      8: </H1>
                      9: <P>
                     10: <STRONG>Written and integrated into libwww by John Punin - thanks!</STRONG>
                     11: <P>
                     12: This module is implemented by <A HREF="HTHash.c">HTHash.c</A>, and is a part
                     13: of the <A HREF="http://www.w3.org/Library/"> W3C Sample Code Library</A>.
                     14: <P>
                     15: This HashTable class implements a simple hash table to keep objects associated
                     16: with key words.
                     17: <PRE>
                     18: #ifndef HTHASH_H
                     19: #define HTHASH_H
                     20: 
                     21: #include "HTList.h"
                     22: 
1.3     ! vbancrof   23: #ifdef __cplusplus
        !            24: extern "C" { 
        !            25: #endif 
        !            26: 
1.1       frystyk    27: typedef struct _HTHashtable HTHashtable;
                     28: 
                     29: struct _HTHashtable {
                     30:     void **table;
                     31:     int count;
                     32:     int size;
                     33: };
                     34:     
                     35: typedef struct _keynode keynode;
                     36: 
                     37: struct _keynode {
                     38:     char *key;
                     39:     void *object;
                     40: };
                     41: </PRE>
                     42: <H2>
                     43:   Creation and Deletion Methods
                     44: </H2>
                     45: <P>
                     46: These methods create and deletes a Hash Table
                     47: <PRE>
                     48: extern HTHashtable *   HTHashtable_new (int size);
                     49: 
                     50: extern BOOL    HTHashtable_delete (HTHashtable *me);
                     51: </PRE>
                     52: <H2>
                     53:   Add an Element to a HashTable
                     54: </H2>
                     55: <PRE>
1.2       kahan      56: extern BOOL HTHashtable_addObject (HTHashtable *me, const char *key, void *newObject);
                     57: </PRE>
                     58: <H2>
                     59:   Remove an Element from a HashTable
                     60: </H2>
                     61: <PRE>
                     62: extern BOOL HTHashtable_removeObject (HTHashtable *me, const char *key);
1.1       frystyk    63: </PRE>
                     64: <H2>
                     65:   Search for an Element in a Hash Table
                     66: </H2>
                     67: <PRE>
                     68: extern void *  HTHashtable_object (HTHashtable * me, const char *key);
                     69: </PRE>
                     70: <H2>
                     71:   Size of a Hash Table
                     72: </H2>
                     73: <PRE>
                     74: extern int     HTHashtable_count  (HTHashtable *me);
                     75: </PRE>
                     76: <H2>
1.2       kahan      77:   Walk all the elements in a Hash Table
                     78: </H2>
                     79: <P>
                     80: Walking the hashtable calls the specified function pointer with each key
                     81: and object that is in the hash table.  If the callback function returns 0,
                     82: the walking stops.  If it returns a negative number, the current element
                     83: is removed from the hash table.  Return a positive number to keep going.
                     84: <P>
                     85: Note that it is legal for the walkFunc to call HTHashtable_removeObject()
                     86: on any element in the current hash table <STRONG>except</STRONG> the current
                     87: one (if you intend to keep going, that is).  The only legal way to delete the
                     88: current element while continuing to walk the table is to use the negative
                     89: return value.
                     90: <PRE>
                     91: extern BOOL    HTHashtable_walk (HTHashtable *me, int (*walkFunc)(HTHashtable *, char *, void *));
                     92: </PRE>
                     93: <H2>
1.1       frystyk    94:   Extract in a dynamic array all keys of the Hash Table
                     95: </H2>
                     96: <PRE>
                     97: extern HTArray * HTHashtable_keys  (HTHashtable *me);
                     98: </PRE>
                     99: <H2>
                    100:   Print the keys of the Hash Table
                    101: </H2>
                    102: <PRE>
                    103: extern void HTHashtable_print (HTHashtable *me);
                    104: </PRE>
                    105: <PRE>
1.3     ! vbancrof  106: #ifdef __cplusplus
        !           107: }
1.1       frystyk   108: #endif
1.3     ! vbancrof  109: 
        !           110: #endif  /* HTHASH_H */
1.1       frystyk   111: </PRE>
                    112: <P>
                    113:   <HR>
                    114: <ADDRESS>
1.3     ! vbancrof  115:   @(#) $Id: HTHash.html,v 1.2 2000/08/11 07:49:07 kahan Exp $
1.1       frystyk   116: </ADDRESS>
                    117: </BODY></HTML>

Webmaster