lwes_hash.h

Go to the documentation of this file.
00001 /*======================================================================*
00002  * Copyright (C) 2008 Light Weight Event System                         *
00003  * All rights reserved.                                                 *
00004  *                                                                      *
00005  * This program is free software; you can redistribute it and/or modify *
00006  * it under the terms of the GNU General Public License as published by *
00007  * the Free Software Foundation; either version 2 of the License, or    *
00008  * (at your option) any later version.                                  *
00009  *                                                                      *
00010  * This program is distributed in the hope that it will be useful,      *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
00013  * GNU General Public License for more details.                         *
00014  *                                                                      *
00015  * You should have received a copy of the GNU General Public License    *
00016  * along with this program; if not, write to the Free Software          *
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor,                   *
00018  * Boston, MA 02110-1301 USA.                                           *
00019  *======================================================================*/
00020 #ifndef __LWES_HASH_H
00021 #define __LWES_HASH_H
00022 
00023 #include <stdlib.h>
00024 #include <stdio.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif 
00029 
00038 struct lwes_hash
00039 {
00040   void **bins;
00041   int total_bins;
00042   int assigned_entries;
00043 };
00044 
00045 struct lwes_hash_element
00046 {
00047   char * key;
00048   void * value;
00049   struct lwes_hash_element *next;
00050 };
00051 
00056 struct lwes_hash_enumeration
00057 {
00058   int index;
00059   int elements_given;
00060   int size_at_start;  /* in case we are using this enumeration to remove all the
00061                          elements in the hash */
00062   struct lwes_hash *enum_hash;
00063   struct lwes_hash_element *current;
00064 };
00065 
00073 struct lwes_hash *
00074 lwes_hash_create
00075   (void);
00076 
00077 struct lwes_hash *
00078 lwes_hash_create_with_bins
00079   (int total_bins);
00080 
00081 int
00082 lwes_hash_destroy
00083   (struct lwes_hash* hash);
00084 
00085 int
00086 lwes_hash_is_empty
00087   (struct lwes_hash* hash);
00088 
00089 int
00090 lwes_hash_size
00091   (struct lwes_hash* hash);
00092 
00093 int
00094 lwes_hash_rehash
00095   (struct lwes_hash* hash);
00096 
00097 int
00098 lwes_hash_put
00099   (struct lwes_hash* hash,
00100    char *key,
00101    void *value);
00102 
00103 void *
00104 lwes_hash_get
00105   (struct lwes_hash* hash,
00106    const char *key);
00107 
00108 void *
00109 lwes_hash_remove
00110   (struct lwes_hash* hash,
00111    const char *key);
00112 
00113 int
00114 lwes_hash_contains_key
00115   (struct lwes_hash* hash,
00116    const char *key);
00117 
00118 int
00119 lwes_hash_keys
00120   (struct lwes_hash * hash,
00121    struct lwes_hash_enumeration *enumeration);
00122 
00123 int
00124 lwes_hash_enumeration_has_more_elements
00125   (struct lwes_hash_enumeration *enumeration);
00126 
00127 char *
00128 lwes_hash_enumeration_next_element
00129   (struct lwes_hash_enumeration *enumeration);
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif 
00134 
00135 #endif /* __LWES_HASH_H */

Generated on Thu Aug 21 07:18:55 2008 for lwes by  doxygen 1.4.6