00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef UHASH_H
00012 #define UHASH_H
00013
00014 #include "unicode/utypes.h"
00015
00070
00071
00072
00073
00074 U_CDECL_BEGIN
00075
00081 typedef int32_t (* U_CALLCONV UHashFunction)(const void* key);
00082
00089 typedef UBool (* U_CALLCONV UKeyComparator)(const void* key1,
00090 const void* key2);
00091
00098 typedef void (* U_CALLCONV UObjectDeleter)(void* obj);
00099
00106 struct UHashElement {
00107 int32_t hashcode;
00108 void* key;
00109 void* value;
00110 };
00111 typedef struct UHashElement UHashElement;
00112
00117 enum UHashResizePolicy {
00118 U_GROW,
00119 U_GROW_AND_SHRINK,
00120 U_FIXED
00121 };
00122
00127 struct UHashtable {
00128
00129
00130
00131 UHashElement *elements;
00132
00133
00134
00135 int32_t count;
00136
00137
00138 int32_t length;
00139
00140 int32_t primeIndex;
00141
00142
00143
00144
00145 int32_t highWaterMark;
00146 int32_t lowWaterMark;
00147 float highWaterRatio;
00148 float lowWaterRatio;
00149
00150
00151
00152 UHashFunction keyHasher;
00153
00154 UKeyComparator keyComparator;
00155
00156 UObjectDeleter keyDeleter;
00157
00158 UObjectDeleter valueDeleter;
00159
00160 };
00161 typedef struct UHashtable UHashtable;
00162
00163 U_CDECL_END
00164
00165
00166
00167
00168
00179 U_CAPI UHashtable*
00180 uhash_open(UHashFunction keyHash,
00181 UKeyComparator keyComp,
00182 UErrorCode *status);
00183
00195 U_CAPI UHashtable*
00196 uhash_openSize(UHashFunction keyHash,
00197 UKeyComparator keyComp,
00198 int32_t size,
00199 UErrorCode *status);
00200
00205 U_CAPI void
00206 uhash_close(UHashtable *hash);
00207
00208
00209
00215 U_CAPI UHashFunction
00216 uhash_setKeyHasher(UHashtable *hash, UHashFunction fn);
00217
00224 U_CAPI UKeyComparator
00225 uhash_setKeyComparator(UHashtable *hash, UKeyComparator fn);
00226
00236 U_CAPI UObjectDeleter
00237 uhash_setKeyDeleter(UHashtable *hash, UObjectDeleter fn);
00238
00248 U_CAPI UObjectDeleter
00249 uhash_setValueDeleter(UHashtable *hash, UObjectDeleter fn);
00250
00256 U_CAPI void
00257 uhash_setResizePolicy(UHashtable *hash, enum UHashResizePolicy policy);
00258
00264 U_CAPI int32_t
00265 uhash_count(const UHashtable *hash);
00266
00279 U_CAPI void*
00280 uhash_put(UHashtable *hash,
00281 void *key,
00282 void *value,
00283 UErrorCode *status);
00284
00291 U_CAPI void*
00292 uhash_get(const UHashtable *hash,
00293 const void *key);
00294
00301 U_CAPI void*
00302 uhash_remove(UHashtable *hash,
00303 const void *key);
00304
00309 U_CAPI void
00310 uhash_removeAll(UHashtable *hash);
00311
00325 U_CAPI const UHashElement*
00326 uhash_nextElement(const UHashtable *hash,
00327 int32_t *pos);
00328
00340 U_CAPI void*
00341 uhash_removeElement(UHashtable *hash, const UHashElement* e);
00342
00343
00344
00345
00346
00354 U_CAPI int32_t
00355 uhash_hashUChars(const void *key);
00356
00364 U_CAPI int32_t
00365 uhash_hashChars(const void *key);
00366
00367
00368 U_CAPI int32_t
00369 uhash_hashUCharsN(const UChar *key, int32_t length);
00370
00378 U_CAPI int32_t
00379 uhash_hashIChars(const void *key);
00380
00385 U_CAPI UBool
00386 uhash_compareUChars(const void *key1, const void *key2);
00387
00392 U_CAPI UBool
00393 uhash_compareChars(const void *key1, const void *key2);
00394
00399 U_CAPI UBool
00400 uhash_compareIChars(const void *key1, const void *key2);
00401
00402
00403
00404
00405
00409 U_CAPI int32_t
00410 uhash_hashUnicodeString(const void *key);
00411
00415 U_CAPI UBool
00416 uhash_compareUnicodeString(const void *key1, const void *key2);
00417
00421 U_CAPI void
00422 uhash_deleteUnicodeString(void *obj);
00423
00424
00425
00426
00427
00431 U_CAPI int32_t
00432 uhash_hashLong(const void *key);
00433
00437 U_CAPI UBool
00438 uhash_compareLong(const void *key1, const void *key2);
00439
00440
00441
00442
00443
00448 U_CAPI void
00449 uhash_freeBlock(void *obj);
00450
00451 #endif