libdacav 0.9.0
|
00001 /* 00002 * Copyright 2009 2010 Giovanni Simoni 00003 * 00004 * This file is part of LibDacav. 00005 * 00006 * LibDacav is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * LibDacav is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with LibDacav. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 */ 00020 00026 #ifndef __defined_dacav_dacavdhash_h 00027 #define __defined_dacav_dacavdhash_h 00028 00029 #ifdef __cplusplus 00030 extern "C" { 00031 #endif 00032 00033 #include <dacav/dacav.h> 00034 #include <stdint.h> 00035 00038 00040 typedef struct dhash dhash_t; 00041 00043 typedef uintptr_t (*dhash_cb_t) (const void *key); 00044 00052 typedef struct pair dhash_pair_t; 00053 00060 typedef enum { 00061 DHASH_FOUND = 0, 00062 DHASH_NOTFOUND = 1, 00063 } dhash_result_t; 00064 00077 const void *dhash_key (dhash_pair_t *p); 00078 00092 void *dhash_val (dhash_pair_t *p); 00093 00119 dhash_t *dhash_new (unsigned nbuckets, dhash_cb_t hf, dcmp_cb_t cmp, 00120 const dcprm_t *key_cprm, const dcprm_t *val_cprm); 00121 00126 void dhash_free (dhash_t *htab); 00127 00142 dhash_result_t dhash_insert (dhash_t *htab, const void *key, 00143 const void *value); 00144 00164 dhash_result_t dhash_search_default (dhash_t *htab, const void *key, 00165 void **found, dcreate_cb_t create, 00166 void *ctx); 00167 00184 dhash_result_t dhash_search (dhash_t *htab, const void *key, void **found); 00185 00202 dhash_result_t dhash_delete (dhash_t *htab, const void *key, void **found); 00203 00213 diter_t *dhash_iter_new (dhash_t *t); 00214 00221 void dhash_iter_free (diter_t *i); 00222 00225 #ifdef __cplusplus 00226 } 00227 #endif 00228 00229 #endif // __defined_dacav_dhash_h