2
+----------------------------------------------------------------------+
4
+----------------------------------------------------------------------+
5
| Copyright (c) 1998-2004 Zend Technologies Ltd. (http://www.zend.com) |
6
+----------------------------------------------------------------------+
7
| This source file is subject to version 2.00 of the Zend license, |
8
| that is bundled with this package in the file LICENSE, and is |
9
| available through the world-wide-web at the following url: |
10
| http://www.zend.com/license/2_00.txt. |
11
| If you did not receive a copy of the Zend license and are unable to |
12
| obtain it through the world-wide-web, please send a note to |
13
| license@zend.com so we can mail you a copy immediately. |
14
+----------------------------------------------------------------------+
15
| Authors: Harald Radi <harald.radi@nme.at> |
16
+----------------------------------------------------------------------+
19
/* $Id: zend_ts_hash.h,v 1.12 2004/01/08 17:31:48 sniper Exp $ */
21
#ifndef ZEND_TS_HASH_H
22
#define ZEND_TS_HASH_H
26
typedef struct _zend_ts_hashtable {
37
#define TS_HASH(table) (&(table->hash))
39
/* startup/shutdown */
40
ZEND_API int _zend_ts_hash_init(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC);
41
ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC);
42
ZEND_API void zend_ts_hash_destroy(TsHashTable *ht);
43
ZEND_API void zend_ts_hash_clean(TsHashTable *ht);
45
#define zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \
46
_zend_ts_hash_init(ht, nSize, pHashFunction, pDestructor, persistent ZEND_FILE_LINE_CC)
47
#define zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection) \
48
_zend_ts_hash_init_ex(ht, nSize, pHashFunction, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_CC)
51
/* additions/updates/changes */
52
ZEND_API int _zend_ts_hash_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
53
#define zend_ts_hash_update(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
54
_zend_ts_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
55
#define zend_ts_hash_add(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
56
_zend_ts_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
58
ZEND_API int _zend_ts_hash_quick_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
59
#define zend_ts_hash_quick_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
60
_zend_ts_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
61
#define zend_ts_hash_quick_add(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
62
_zend_ts_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
64
ZEND_API int _zend_ts_hash_index_update_or_next_insert(TsHashTable *ht, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
65
#define zend_ts_hash_index_update(ht, h, pData, nDataSize, pDest) \
66
_zend_ts_hash_index_update_or_next_insert(ht, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
67
#define zend_ts_hash_next_index_insert(ht, pData, nDataSize, pDest) \
68
_zend_ts_hash_index_update_or_next_insert(ht, 0, pData, nDataSize, pDest, HASH_NEXT_INSERT ZEND_FILE_LINE_CC)
70
ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint nKeyLength);
72
ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht);
73
ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC);
74
ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void * TSRMLS_DC);
75
ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht, apply_func_args_t apply_func, int, ...);
77
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC);
81
ZEND_API int zend_ts_hash_del_key_or_index(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag);
82
#define zend_ts_hash_del(ht, arKey, nKeyLength) \
83
zend_ts_hash_del_key_or_index(ht, arKey, nKeyLength, 0, HASH_DEL_KEY)
84
#define zend_ts_hash_index_del(ht, h) \
85
zend_ts_hash_del_key_or_index(ht, NULL, 0, h, HASH_DEL_INDEX)
87
ZEND_API ulong zend_ts_get_hash_value(TsHashTable *ht, char *arKey, uint nKeyLength);
90
ZEND_API int zend_ts_hash_find(TsHashTable *ht, char *arKey, uint nKeyLength, void **pData);
91
ZEND_API int zend_ts_hash_quick_find(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void **pData);
92
ZEND_API int zend_ts_hash_index_find(TsHashTable *ht, ulong h, void **pData);
95
ZEND_API int zend_ts_hash_exists(TsHashTable *ht, char *arKey, uint nKeyLength);
96
ZEND_API int zend_ts_hash_index_exists(TsHashTable *ht, ulong h);
98
/* Copying, merging and sorting */
99
ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size);
100
ZEND_API void zend_ts_hash_merge(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size, int overwrite);
101
ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam);
102
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC);
103
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC);
104
ZEND_API int zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC);
106
ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht);
108
ZEND_API int zend_ts_hash_rehash(TsHashTable *ht);
110
ZEND_API ulong zend_ts_hash_func(char *arKey, uint nKeyLength);
114
void zend_ts_hash_display_pListTail(TsHashTable *ht);
115
void zend_ts_hash_display(TsHashTable *ht);
120
#define ZEND_TS_INIT_SYMTABLE(ht) \
121
ZEND_TS_INIT_SYMTABLE_EX(ht, 2, 0)
123
#define ZEND_TS_INIT_SYMTABLE_EX(ht, n, persistent) \
124
zend_ts_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
126
#endif /* ZEND_HASH_H */
132
* indent-tabs-mode: t