~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to Zend/zend_ts_hash.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   +----------------------------------------------------------------------+
 
3
   | Zend Engine                                                          |
 
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
   +----------------------------------------------------------------------+
 
17
*/
 
18
 
 
19
/* $Id: zend_ts_hash.h,v 1.12 2004/01/08 17:31:48 sniper Exp $ */
 
20
 
 
21
#ifndef ZEND_TS_HASH_H
 
22
#define ZEND_TS_HASH_H
 
23
 
 
24
#include "zend.h"
 
25
 
 
26
typedef struct _zend_ts_hashtable {
 
27
        HashTable hash;
 
28
        zend_uint reader;
 
29
#ifdef ZTS
 
30
        MUTEX_T mx_reader;
 
31
        MUTEX_T mx_writer;
 
32
#endif
 
33
} TsHashTable;
 
34
 
 
35
BEGIN_EXTERN_C()
 
36
 
 
37
#define TS_HASH(table) (&(table->hash))
 
38
 
 
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);
 
44
 
 
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)
 
49
 
 
50
 
 
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)
 
57
 
 
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)
 
63
 
 
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)
 
69
 
 
70
ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint nKeyLength);
 
71
 
 
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, ...);
 
76
 
 
77
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC);
 
78
 
 
79
 
 
80
/* Deletes */
 
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)
 
86
 
 
87
ZEND_API ulong zend_ts_get_hash_value(TsHashTable *ht, char *arKey, uint nKeyLength);
 
88
 
 
89
/* Data retreival */
 
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);
 
93
 
 
94
/* Misc */
 
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);
 
97
 
 
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);
 
105
 
 
106
ZEND_API int zend_ts_hash_num_elements(TsHashTable *ht);
 
107
 
 
108
ZEND_API int zend_ts_hash_rehash(TsHashTable *ht);
 
109
 
 
110
ZEND_API ulong zend_ts_hash_func(char *arKey, uint nKeyLength);
 
111
 
 
112
#if ZEND_DEBUG
 
113
/* debug */
 
114
void zend_ts_hash_display_pListTail(TsHashTable *ht);
 
115
void zend_ts_hash_display(TsHashTable *ht);
 
116
#endif
 
117
 
 
118
END_EXTERN_C()
 
119
 
 
120
#define ZEND_TS_INIT_SYMTABLE(ht)                                                               \
 
121
        ZEND_TS_INIT_SYMTABLE_EX(ht, 2, 0)
 
122
 
 
123
#define ZEND_TS_INIT_SYMTABLE_EX(ht, n, persistent)                     \
 
124
        zend_ts_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent)
 
125
 
 
126
#endif                                                  /* ZEND_HASH_H */
 
127
 
 
128
/*
 
129
 * Local variables:
 
130
 * tab-width: 4
 
131
 * c-basic-offset: 4
 
132
 * indent-tabs-mode: t
 
133
 * End:
 
134
 */