1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
* Copyright (c) 2011-2018, Meituan Dianping. All Rights Reserved.
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// simple implement of concurrentHashMap
// hash item
extern dictType dictTypeHeapStringCopyKey;
extern dictType dictTypeHeapStrings;
extern dictType dictTypeHeapStringCopyKeyFreeVal;
typedef struct _CCHashSlot CCHashSlot;
// hash map
typedef struct _CCHashMap CCHashMap;
/** Defines Val operate function for CCHashMap find. */
typedef void;
/** Defines Val create function for CCHashMap find. */
typedef void *;
/**********************************************************************************************//**
* Creates Concurrent hash map.
*
* @param [in] type If non-null, the type.
* @param slotCount Number of slots.
* @param [in] privDataPtr If non-null, the private data pointer.
*
* @return null if it fails, else the new Concurrent hash map.
**************************************************************************************************/
CCHashMap *;
/**********************************************************************************************//**
* Find the corresponding value in CCHashMap with key, return null if it fails, else the corresponding value
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
*
* @return null if it fails, else the corresponding value
**************************************************************************************************/
void *;
/**********************************************************************************************//**
* Find the corresponding value in CCHashMap with key, return defaultVal if it dos'nt contain this key,
* else the corresponding value
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param [in] defaultVal If non-null, the default value.
*
* @return defaultVal if there is no this key, else the corresponding value
**************************************************************************************************/
void *;
/**********************************************************************************************//**
* Find the corresponding value in CCHashMap with key.
* If it dos'nt contain this key, then create and insert the key-val pair with val:createVal.
* Only if pCCHM is invalid, the function will always return the corresponding value.
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param [in] createVal If non-null, the create value.
*
* @return null if it fails, else the found Cc hash map create.
**************************************************************************************************/
void *;
/**********************************************************************************************//**
* Find the corresponding value in CCHashMap with key. If it dos'nt contain this key, then
* create and insert the key-val pair by calling Fun:createFun. Only if pCCHM is invalid, the function
* will always return the corresponding value.
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param [in] createFun If non-null, the create value.
* @param [in] createParam If non-null, the create parameter.
*
* @return null if it fails, else the found Cc hash map create.
**************************************************************************************************/
void *;
/**********************************************************************************************//**
* Find the corresponding value in CCHashMap with key, return defaultVal if it dos'nt contain this key,
* else the corresponding value.
* If the key is found, then call the optFun with param: pCCHM, key, &val, param.
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param optFun The option fun.
*
* @return null if it fails, else the found Cc hash map and operate.
**************************************************************************************************/
void *;
/**********************************************************************************************//**
* Find the corresponding value in CCHashMap with key. If it dos'nt contain this key, then
* create and insert the key-val pair by calling Fun:createFun.
* Then call the optFun with param: pCCHM, key, &val, param.
* Only if pCCHM is invalid, the function will always return the corresponding value.
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param [in] createFun If non-null, the create value.
* @param [in] createParam If non-null, the create parameter.
* @param optFun The option fun.
* @param [in,out] optParam If non-null, the option parameter.
*
* @return null if it fails, else the found Cc hash map create.
**************************************************************************************************/
void *
;
/**********************************************************************************************//**
* put the key-val pair in CCHashMap, if the key exist, return fail
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param [in] pVal If non-null, the value.
*
* @return An int.
**************************************************************************************************/
int ;
/**********************************************************************************************//**
* replace the key-val pair in CCHashMap, only if pCCHM is invalid, the function will always return success
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
* @param [in] pVal If non-null, the value.
*
* @return An int.
**************************************************************************************************/
int ;
/**********************************************************************************************//**
* Removes the key in CCHashMap.
*
* @param [in] pCCHM If non-null, the cchm.
* @param [in] key If non-null, the key.
*
* @return An int.
**************************************************************************************************/
int ;
/**********************************************************************************************//**
* Clears the Cc hash map described by pCCHM.
*
* @param [in,out] pCCHM If non-null, the cchm.
**************************************************************************************************/
void ;
/**********************************************************************************************//**
* Move all dict in CCHashMap to a dict pointer array, the dict * is NULL if there is no more dict
* User need to call freeDictArray to free the array
*
* @param [in,out] pCCHM If non-null, the cchm.
*
* @return null if it fails, else a dict**.
**************************************************************************************************/
dict **;
/**********************************************************************************************//**
* Free dict pointer array.
*
* @param [in,out] ppDict If non-null, the dictionary.
**************************************************************************************************/
void ;
void ;
void ;
}
//CONCURRENT_HASH_MAP_h__