BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

hash.h
Go to the documentation of this file.
1 /* $Id: hash.h 4208 2012-07-18 07:52:33Z ming $ */
2 /*
3  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 #ifndef __PJ_HASH_H__
21 #define __PJ_HASH_H__
22 
28 #include <pj/types.h>
29 
31 
46 #define PJ_HASH_KEY_STRING ((unsigned)-1)
47 
51 #define PJ_HASH_ENTRY_BUF_SIZE (3*sizeof(void*) + 2*sizeof(pj_uint32_t))
52 
56 typedef void *pj_hash_entry_buf[(PJ_HASH_ENTRY_BUF_SIZE+sizeof(void*)-1)/(sizeof(void*))];
57 
69 PJ_DECL(pj_uint32_t) pj_hash_calc(pj_uint32_t hval,
70  const void *key, unsigned keylen);
71 
72 
85  char *result,
86  const pj_str_t *key);
87 
96 PJ_DECL(pj_hash_table_t*) pj_hash_create(pj_pool_t *pool, unsigned size);
97 
98 
113 PJ_DECL(void *) pj_hash_get( pj_hash_table_t *ht,
114  const void *key, unsigned keylen,
115  pj_uint32_t *hval );
116 
117 
124 PJ_DECL(void *) pj_hash_get_lower( pj_hash_table_t *ht,
125  const void *key, unsigned keylen,
126  pj_uint32_t *hval );
127 
128 
150 PJ_DECL(void) pj_hash_set( pj_pool_t *pool, pj_hash_table_t *ht,
151  const void *key, unsigned keylen, pj_uint32_t hval,
152  void *value );
153 
154 
161 PJ_DECL(void) pj_hash_set_lower( pj_pool_t *pool, pj_hash_table_t *ht,
162  const void *key, unsigned keylen,
163  pj_uint32_t hval, void *value );
164 
165 
184 PJ_DECL(void) pj_hash_set_np(pj_hash_table_t *ht,
185  const void *key, unsigned keylen,
186  pj_uint32_t hval, pj_hash_entry_buf entry_buf,
187  void *value);
188 
195 PJ_DECL(void) pj_hash_set_np_lower(pj_hash_table_t *ht,
196  const void *key, unsigned keylen,
197  pj_uint32_t hval,
198  pj_hash_entry_buf entry_buf,
199  void *value);
200 
208 PJ_DECL(unsigned) pj_hash_count( pj_hash_table_t *ht );
209 
210 
220  pj_hash_iterator_t *it );
221 
222 
232  pj_hash_iterator_t *it );
233 
242 PJ_DECL(void*) pj_hash_this( pj_hash_table_t *ht,
243  pj_hash_iterator_t *it );
244 
245 
251 
252 #endif
253 
254 
struct pj_hash_table_t pj_hash_table_t
Definition: types.h:167
pj_uint32_t pj_hash_calc_tolower(pj_uint32_t hval, char *result, const pj_str_t *key)
Declaration of basic types and utility.
void * pj_hash_this(pj_hash_table_t *ht, pj_hash_iterator_t *it)
void * pj_hash_get_lower(pj_hash_table_t *ht, const void *key, unsigned keylen, pj_uint32_t *hval)
Definition: types.h:179
void * pj_hash_entry_buf[((3 *sizeof(void *)+2 *sizeof(pj_uint32_t))+sizeof(void *)-1)/(sizeof(void *))]
Definition: hash.h:56
Definition: types.h:119
pj_hash_table_t * pj_hash_create(pj_pool_t *pool, unsigned size)
unsigned int pj_uint32_t
Definition: types.h:43
void * pj_hash_get(pj_hash_table_t *ht, const void *key, unsigned keylen, pj_uint32_t *hval)
#define PJ_END_DECL
Definition: config.h:1067
#define PJ_BEGIN_DECL
Definition: config.h:1066
void pj_hash_set_np_lower(pj_hash_table_t *ht, const void *key, unsigned keylen, pj_uint32_t hval, pj_hash_entry_buf entry_buf, void *value)
void pj_hash_set_lower(pj_pool_t *pool, pj_hash_table_t *ht, const void *key, unsigned keylen, pj_uint32_t hval, void *value)
void pj_hash_set(pj_pool_t *pool, pj_hash_table_t *ht, const void *key, unsigned keylen, pj_uint32_t hval, void *value)
Definition: pool.h:313
unsigned pj_hash_count(pj_hash_table_t *ht)
void pj_hash_set_np(pj_hash_table_t *ht, const void *key, unsigned keylen, pj_uint32_t hval, pj_hash_entry_buf entry_buf, void *value)
pj_hash_iterator_t * pj_hash_next(pj_hash_table_t *ht, pj_hash_iterator_t *it)
pj_hash_iterator_t * pj_hash_first(pj_hash_table_t *ht, pj_hash_iterator_t *it)
pj_uint32_t pj_hash_calc(pj_uint32_t hval, const void *key, unsigned keylen)
#define PJ_HASH_ENTRY_BUF_SIZE
Definition: hash.h:51

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.