]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/uhash.h
ICU-400.42.tar.gz
[apple/icu.git] / icuSources / common / uhash.h
1 /*
2 ******************************************************************************
3 * Copyright (C) 1997-2007, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
6 * Date Name Description
7 * 03/22/00 aliu Adapted from original C++ ICU Hashtable.
8 * 07/06/01 aliu Modified to support int32_t keys on
9 * platforms with sizeof(void*) < 32.
10 ******************************************************************************
11 */
12
13 #ifndef UHASH_H
14 #define UHASH_H
15
16 #include "unicode/utypes.h"
17
18 /**
19 * UHashtable stores key-value pairs and does moderately fast lookup
20 * based on keys. It provides a good tradeoff between access time and
21 * storage space. As elements are added to it, it grows to accomodate
22 * them. By default, the table never shrinks, even if all elements
23 * are removed from it.
24 *
25 * Keys and values are stored as void* pointers. These void* pointers
26 * may be actual pointers to strings, objects, or any other structure
27 * in memory, or they may simply be integral values cast to void*.
28 * UHashtable doesn't care and manipulates them via user-supplied
29 * functions. These functions hash keys, compare keys, delete keys,
30 * and delete values. Some function pointers are optional (may be
31 * NULL); others must be supplied. Several prebuilt functions exist
32 * to handle common key types.
33 *
34 * UHashtable ownership of keys and values is flexible, and controlled
35 * by whether or not the key deleter and value deleter functions are
36 * set. If a void* key is actually a pointer to a deletable object,
37 * then UHashtable can be made to delete that object by setting the
38 * key deleter function pointer to a non-NULL value. If this is done,
39 * then keys passed to uhash_put() are owned by the hashtable and will
40 * be deleted by it at some point, either as keys are replaced, or
41 * when uhash_close() is finally called. The same is true of values
42 * and the value deleter function pointer. Keys passed to methods
43 * other than uhash_put() are never owned by the hashtable.
44 *
45 * NULL values are not allowed. uhash_get() returns NULL to indicate
46 * a key that is not in the table, and having a NULL value in the
47 * table would generate an ambiguous result. If a key and a NULL
48 * value is passed to uhash_put(), this has the effect of doing a
49 * uhash_remove() on that key. This keeps uhash_get(), uhash_count(),
50 * and uhash_nextElement() consistent with one another.
51 *
52 * To see everything in a hashtable, use uhash_nextElement() to
53 * iterate through its contents. Each call to this function returns a
54 * UHashElement pointer. A hash element contains a key, value, and
55 * hashcode. During iteration an element may be deleted by calling
56 * uhash_removeElement(); iteration may safely continue thereafter.
57 * The uhash_remove() function may also be safely called in
58 * mid-iteration. However, if uhash_put() is called during iteration
59 * then the iteration will be out of sync. Under no circumstances
60 * should the UHashElement returned by uhash_nextElement be modified
61 * directly.
62 *
63 * By default, the hashtable grows when necessary, but never shrinks,
64 * even if all items are removed. For most applications this is
65 * optimal. However, in a highly dynamic usage where memory is at a
66 * premium, the table can be set to both grow and shrink by calling
67 * uhash_setResizePolicy() with the policy U_GROW_AND_SHRINK. In a
68 * situation where memory is critical and the client wants a table
69 * that does not grow at all, the constant U_FIXED can be used.
70 */
71
72 /********************************************************************
73 * Data Structures
74 ********************************************************************/
75
76 U_CDECL_BEGIN
77
78 /**
79 * A key or value within the hashtable. It may be either a 32-bit
80 * integral value or an opaque void* pointer. The void* pointer may
81 * be smaller than 32 bits (e.g. 24 bits) or may be larger (e.g. 64
82 * bits). The hashing and comparison functions take a pointer to a
83 * UHashTok, but the deleter receives the void* pointer within it.
84 *
85 * Because a UHashTok is the size of a native pointer or a 32-bit
86 * integer, we pass it around by value.
87 */
88 union UHashTok {
89 void* pointer;
90 int32_t integer;
91 };
92 typedef union UHashTok UHashTok;
93
94 /**
95 * This is a single hash element.
96 */
97 struct UHashElement {
98 /* Reorder these elements to pack nicely if necessary */
99 int32_t hashcode;
100 UHashTok value;
101 UHashTok key;
102 };
103 typedef struct UHashElement UHashElement;
104
105 /**
106 * A hashing function.
107 * @param key A key stored in a hashtable
108 * @return A NON-NEGATIVE hash code for parm.
109 */
110 typedef int32_t U_CALLCONV UHashFunction(const UHashTok key);
111
112 /**
113 * A key comparison function.
114 * @param key1 A key stored in a hashtable
115 * @param key2 A key stored in a hashtable
116 * @return TRUE if the two keys are equal.
117 */
118 typedef UBool U_CALLCONV UKeyComparator(const UHashTok key1,
119 const UHashTok key2);
120 /**
121 * A key comparison function.
122 * @param val1 A key stored in a hashtable
123 * @param val2 A key stored in a hashtable
124 * @return TRUE if the two keys are equal.
125 */
126 typedef UBool U_CALLCONV UValueComparator(const UHashTok val1,
127 const UHashTok val2);
128 /**
129 * A function called by <TT>uhash_remove</TT>,
130 * <TT>uhash_close</TT>, or <TT>uhash_put</TT> to delete
131 * an existing key or value.
132 * @param obj A key or value stored in a hashtable
133 */
134 typedef void U_CALLCONV UObjectDeleter(void* obj);
135
136 /**
137 * This specifies whether or not, and how, the hastable resizes itself.
138 * See uhash_setResizePolicy().
139 */
140 enum UHashResizePolicy {
141 U_GROW, /* Grow on demand, do not shrink */
142 U_GROW_AND_SHRINK, /* Grow and shrink on demand */
143 U_FIXED /* Never change size */
144 };
145
146 /**
147 * The UHashtable struct. Clients should treat this as an opaque data
148 * type and manipulate it only through the uhash_... API.
149 */
150 struct UHashtable {
151
152 /* Main key-value pair storage array */
153
154 UHashElement *elements;
155
156 /* Function pointers */
157
158 UHashFunction *keyHasher; /* Computes hash from key.
159 * Never null. */
160 UKeyComparator *keyComparator; /* Compares keys for equality.
161 * Never null. */
162 UValueComparator *valueComparator; /* Compares the values for equality */
163
164 UObjectDeleter *keyDeleter; /* Deletes keys when required.
165 * If NULL won't do anything */
166 UObjectDeleter *valueDeleter; /* Deletes values when required.
167 * If NULL won't do anything */
168
169 /* Size parameters */
170
171 int32_t count; /* The number of key-value pairs in this table.
172 * 0 <= count <= length. In practice we
173 * never let count == length (see code). */
174 int32_t length; /* The physical size of the arrays hashes, keys
175 * and values. Must be prime. */
176
177 /* Rehashing thresholds */
178
179 int32_t highWaterMark; /* If count > highWaterMark, rehash */
180 int32_t lowWaterMark; /* If count < lowWaterMark, rehash */
181 float highWaterRatio; /* 0..1; high water as a fraction of length */
182 float lowWaterRatio; /* 0..1; low water as a fraction of length */
183
184 int8_t primeIndex; /* Index into our prime table for length.
185 * length == PRIMES[primeIndex] */
186 UBool allocated; /* Was this UHashtable allocated? */
187 };
188 typedef struct UHashtable UHashtable;
189
190 U_CDECL_END
191
192 /********************************************************************
193 * API
194 ********************************************************************/
195
196 /**
197 * Initialize a new UHashtable.
198 * @param keyHash A pointer to the key hashing function. Must not be
199 * NULL.
200 * @param keyComp A pointer to the function that compares keys. Must
201 * not be NULL.
202 * @param status A pointer to an UErrorCode to receive any errors.
203 * @return A pointer to a UHashtable, or 0 if an error occurred.
204 * @see uhash_openSize
205 */
206 U_CAPI UHashtable* U_EXPORT2
207 uhash_open(UHashFunction *keyHash,
208 UKeyComparator *keyComp,
209 UValueComparator *valueComp,
210 UErrorCode *status);
211
212 /**
213 * Initialize a new UHashtable with a given initial size.
214 * @param keyHash A pointer to the key hashing function. Must not be
215 * NULL.
216 * @param keyComp A pointer to the function that compares keys. Must
217 * not be NULL.
218 * @param size The initial capacity of this hash table.
219 * @param status A pointer to an UErrorCode to receive any errors.
220 * @return A pointer to a UHashtable, or 0 if an error occurred.
221 * @see uhash_open
222 */
223 U_CAPI UHashtable* U_EXPORT2
224 uhash_openSize(UHashFunction *keyHash,
225 UKeyComparator *keyComp,
226 UValueComparator *valueComp,
227 int32_t size,
228 UErrorCode *status);
229
230 /**
231 * Initialize an existing UHashtable.
232 * @param keyHash A pointer to the key hashing function. Must not be
233 * NULL.
234 * @param keyComp A pointer to the function that compares keys. Must
235 * not be NULL.
236 * @param status A pointer to an UErrorCode to receive any errors.
237 * @return A pointer to a UHashtable, or 0 if an error occurred.
238 * @see uhash_openSize
239 */
240 U_CAPI UHashtable* U_EXPORT2
241 uhash_init(UHashtable *hash,
242 UHashFunction *keyHash,
243 UKeyComparator *keyComp,
244 UValueComparator *valueComp,
245 UErrorCode *status);
246
247 /**
248 * Close a UHashtable, releasing the memory used.
249 * @param hash The UHashtable to close.
250 */
251 U_CAPI void U_EXPORT2
252 uhash_close(UHashtable *hash);
253
254
255
256 /**
257 * Set the function used to hash keys.
258 * @param hash The UHashtable to set
259 * @param fn the function to be used hash keys; must not be NULL
260 * @return the previous key hasher; non-NULL
261 */
262 U_CAPI UHashFunction *U_EXPORT2
263 uhash_setKeyHasher(UHashtable *hash, UHashFunction *fn);
264
265 /**
266 * Set the function used to compare keys. The default comparison is a
267 * void* pointer comparison.
268 * @param hash The UHashtable to set
269 * @param fn the function to be used compare keys; must not be NULL
270 * @return the previous key comparator; non-NULL
271 */
272 U_CAPI UKeyComparator *U_EXPORT2
273 uhash_setKeyComparator(UHashtable *hash, UKeyComparator *fn);
274
275 /**
276 * Set the function used to compare values. The default comparison is a
277 * void* pointer comparison.
278 * @param hash The UHashtable to set
279 * @param fn the function to be used compare keys; must not be NULL
280 * @return the previous key comparator; non-NULL
281 */
282 U_CAPI UValueComparator *U_EXPORT2
283 uhash_setValueComparator(UHashtable *hash, UValueComparator *fn);
284
285 /**
286 * Set the function used to delete keys. If this function pointer is
287 * NULL, this hashtable does not delete keys. If it is non-NULL, this
288 * hashtable does delete keys. This function should be set once
289 * before any elements are added to the hashtable and should not be
290 * changed thereafter.
291 * @param hash The UHashtable to set
292 * @param fn the function to be used delete keys, or NULL
293 * @return the previous key deleter; may be NULL
294 */
295 U_CAPI UObjectDeleter *U_EXPORT2
296 uhash_setKeyDeleter(UHashtable *hash, UObjectDeleter *fn);
297
298 /**
299 * Set the function used to delete values. If this function pointer
300 * is NULL, this hashtable does not delete values. If it is non-NULL,
301 * this hashtable does delete values. This function should be set
302 * once before any elements are added to the hashtable and should not
303 * be changed thereafter.
304 * @param hash The UHashtable to set
305 * @param fn the function to be used delete values, or NULL
306 * @return the previous value deleter; may be NULL
307 */
308 U_CAPI UObjectDeleter *U_EXPORT2
309 uhash_setValueDeleter(UHashtable *hash, UObjectDeleter *fn);
310
311 /**
312 * Specify whether or not, and how, the hastable resizes itself.
313 * By default, tables grow but do not shrink (policy U_GROW).
314 * See enum UHashResizePolicy.
315 * @param hash The UHashtable to set
316 * @param policy The way the hashtable resizes itself, {U_GROW, U_GROW_AND_SHRINK, U_FIXED}
317 */
318 U_CAPI void U_EXPORT2
319 uhash_setResizePolicy(UHashtable *hash, enum UHashResizePolicy policy);
320
321 /**
322 * Get the number of key-value pairs stored in a UHashtable.
323 * @param hash The UHashtable to query.
324 * @return The number of key-value pairs stored in hash.
325 */
326 U_CAPI int32_t U_EXPORT2
327 uhash_count(const UHashtable *hash);
328
329 /**
330 * Put a (key=pointer, value=pointer) item in a UHashtable. If the
331 * keyDeleter is non-NULL, then the hashtable owns 'key' after this
332 * call. If the valueDeleter is non-NULL, then the hashtable owns
333 * 'value' after this call. Storing a NULL value is the same as
334 * calling uhash_remove().
335 * @param hash The target UHashtable.
336 * @param key The key to store.
337 * @param value The value to store, may be NULL (see above).
338 * @param status A pointer to an UErrorCode to receive any errors.
339 * @return The previous value, or NULL if none.
340 * @see uhash_get
341 */
342 U_CAPI void* U_EXPORT2
343 uhash_put(UHashtable *hash,
344 void *key,
345 void *value,
346 UErrorCode *status);
347
348 /**
349 * Put a (key=integer, value=pointer) item in a UHashtable.
350 * keyDeleter must be NULL. If the valueDeleter is non-NULL, then the
351 * hashtable owns 'value' after this call. Storing a NULL value is
352 * the same as calling uhash_remove().
353 * @param hash The target UHashtable.
354 * @param key The integer key to store.
355 * @param value The value to store, may be NULL (see above).
356 * @param status A pointer to an UErrorCode to receive any errors.
357 * @return The previous value, or NULL if none.
358 * @see uhash_get
359 */
360 U_CAPI void* U_EXPORT2
361 uhash_iput(UHashtable *hash,
362 int32_t key,
363 void* value,
364 UErrorCode *status);
365
366 /**
367 * Put a (key=pointer, value=integer) item in a UHashtable. If the
368 * keyDeleter is non-NULL, then the hashtable owns 'key' after this
369 * call. valueDeleter must be NULL. Storing a 0 value is the same as
370 * calling uhash_remove().
371 * @param hash The target UHashtable.
372 * @param key The key to store.
373 * @param value The integer value to store.
374 * @param status A pointer to an UErrorCode to receive any errors.
375 * @return The previous value, or 0 if none.
376 * @see uhash_get
377 */
378 U_CAPI int32_t U_EXPORT2
379 uhash_puti(UHashtable *hash,
380 void* key,
381 int32_t value,
382 UErrorCode *status);
383
384 /**
385 * Put a (key=integer, value=integer) item in a UHashtable. If the
386 * keyDeleter is non-NULL, then the hashtable owns 'key' after this
387 * call. valueDeleter must be NULL. Storing a 0 value is the same as
388 * calling uhash_remove().
389 * @param hash The target UHashtable.
390 * @param key The key to store.
391 * @param value The integer value to store.
392 * @param status A pointer to an UErrorCode to receive any errors.
393 * @return The previous value, or 0 if none.
394 * @see uhash_get
395 */
396 U_CAPI int32_t U_EXPORT2
397 uhash_iputi(UHashtable *hash,
398 int32_t key,
399 int32_t value,
400 UErrorCode *status);
401
402 /**
403 * Retrieve a pointer value from a UHashtable using a pointer key,
404 * as previously stored by uhash_put().
405 * @param hash The target UHashtable.
406 * @param key A pointer key stored in a hashtable
407 * @return The requested item, or NULL if not found.
408 */
409 U_CAPI void* U_EXPORT2
410 uhash_get(const UHashtable *hash,
411 const void *key);
412
413 /**
414 * Retrieve a pointer value from a UHashtable using a integer key,
415 * as previously stored by uhash_iput().
416 * @param hash The target UHashtable.
417 * @param key An integer key stored in a hashtable
418 * @return The requested item, or NULL if not found.
419 */
420 U_CAPI void* U_EXPORT2
421 uhash_iget(const UHashtable *hash,
422 int32_t key);
423
424 /**
425 * Retrieve an integer value from a UHashtable using a pointer key,
426 * as previously stored by uhash_puti().
427 * @param hash The target UHashtable.
428 * @param key A pointer key stored in a hashtable
429 * @return The requested item, or 0 if not found.
430 */
431 U_CAPI int32_t U_EXPORT2
432 uhash_geti(const UHashtable *hash,
433 const void* key);
434 /**
435 * Retrieve an integer value from a UHashtable using an integer key,
436 * as previously stored by uhash_iputi().
437 * @param hash The target UHashtable.
438 * @param key An integer key stored in a hashtable
439 * @return The requested item, or 0 if not found.
440 */
441 U_CAPI int32_t U_EXPORT2
442 uhash_igeti(const UHashtable *hash,
443 int32_t key);
444
445 /**
446 * Remove an item from a UHashtable stored by uhash_put().
447 * @param hash The target UHashtable.
448 * @param key A key stored in a hashtable
449 * @return The item removed, or NULL if not found.
450 */
451 U_CAPI void* U_EXPORT2
452 uhash_remove(UHashtable *hash,
453 const void *key);
454
455 /**
456 * Remove an item from a UHashtable stored by uhash_iput().
457 * @param hash The target UHashtable.
458 * @param key An integer key stored in a hashtable
459 * @return The item removed, or NULL if not found.
460 */
461 U_CAPI void* U_EXPORT2
462 uhash_iremove(UHashtable *hash,
463 int32_t key);
464
465 /**
466 * Remove an item from a UHashtable stored by uhash_puti().
467 * @param hash The target UHashtable.
468 * @param key An key stored in a hashtable
469 * @return The item removed, or 0 if not found.
470 */
471 U_CAPI int32_t U_EXPORT2
472 uhash_removei(UHashtable *hash,
473 const void* key);
474
475 /**
476 * Remove an item from a UHashtable stored by uhash_iputi().
477 * @param hash The target UHashtable.
478 * @param key An integer key stored in a hashtable
479 * @return The item removed, or 0 if not found.
480 */
481 U_CAPI int32_t U_EXPORT2
482 uhash_iremovei(UHashtable *hash,
483 int32_t key);
484
485 /**
486 * Remove all items from a UHashtable.
487 * @param hash The target UHashtable.
488 */
489 U_CAPI void U_EXPORT2
490 uhash_removeAll(UHashtable *hash);
491
492 /**
493 * Locate an element of a UHashtable. The caller must not modify the
494 * returned object. The primary use of this function is to obtain the
495 * stored key when it may not be identical to the search key. For
496 * example, if the compare function is a case-insensitive string
497 * compare, then the hash key may be desired in order to obtain the
498 * canonical case corresponding to a search key.
499 * @param hash The target UHashtable.
500 * @param key A key stored in a hashtable
501 * @return a hash element, or NULL if the key is not found.
502 */
503 U_CAPI const UHashElement* U_EXPORT2
504 uhash_find(const UHashtable *hash, const void* key);
505
506 /**
507 * Iterate through the elements of a UHashtable. The caller must not
508 * modify the returned object. However, uhash_removeElement() may be
509 * called during iteration to remove an element from the table.
510 * Iteration may safely be resumed afterwards. If uhash_put() is
511 * called during iteration the iteration will then be out of sync and
512 * should be restarted.
513 * @param hash The target UHashtable.
514 * @param pos This should be set to -1 initially, and left untouched
515 * thereafter.
516 * @return a hash element, or NULL if no further key-value pairs
517 * exist in the table.
518 */
519 U_CAPI const UHashElement* U_EXPORT2
520 uhash_nextElement(const UHashtable *hash,
521 int32_t *pos);
522
523 /**
524 * Remove an element, returned by uhash_nextElement(), from the table.
525 * Iteration may be safely continued afterwards.
526 * @param hash The hashtable
527 * @param e The element, returned by uhash_nextElement(), to remove.
528 * Must not be NULL. Must not be an empty or deleted element (as long
529 * as this was returned by uhash_nextElement() it will not be empty or
530 * deleted). Note: Although this parameter is const, it will be
531 * modified.
532 * @return the value that was removed.
533 */
534 U_CAPI void* U_EXPORT2
535 uhash_removeElement(UHashtable *hash, const UHashElement* e);
536
537 /********************************************************************
538 * UHashTok convenience
539 ********************************************************************/
540
541 /**
542 * Return a UHashTok for an integer.
543 * @param i The given integer
544 * @return a UHashTok for an integer.
545 */
546 /*U_CAPI UHashTok U_EXPORT2
547 uhash_toki(int32_t i);*/
548
549 /**
550 * Return a UHashTok for a pointer.
551 * @param p The given pointer
552 * @return a UHashTok for a pointer.
553 */
554 /*U_CAPI UHashTok U_EXPORT2
555 uhash_tokp(void* p);*/
556
557 /********************************************************************
558 * UChar* and char* Support Functions
559 ********************************************************************/
560
561 /**
562 * Generate a hash code for a null-terminated UChar* string. If the
563 * string is not null-terminated do not use this function. Use
564 * together with uhash_compareUChars.
565 * @param key The string (const UChar*) to hash.
566 * @return A hash code for the key.
567 */
568 U_CAPI int32_t U_EXPORT2
569 uhash_hashUChars(const UHashTok key);
570
571 /**
572 * Generate a hash code for a null-terminated char* string. If the
573 * string is not null-terminated do not use this function. Use
574 * together with uhash_compareChars.
575 * @param key The string (const char*) to hash.
576 * @return A hash code for the key.
577 */
578 U_CAPI int32_t U_EXPORT2
579 uhash_hashChars(const UHashTok key);
580
581 /* Used by UnicodeString to compute its hashcode - Not public API. */
582 U_CAPI int32_t U_EXPORT2
583 uhash_hashUCharsN(const UChar *key, int32_t length);
584
585 /**
586 * Generate a case-insensitive hash code for a null-terminated char*
587 * string. If the string is not null-terminated do not use this
588 * function. Use together with uhash_compareIChars.
589 * @param key The string (const char*) to hash.
590 * @return A hash code for the key.
591 */
592 U_CAPI int32_t U_EXPORT2
593 uhash_hashIChars(const UHashTok key);
594
595 /**
596 * Comparator for null-terminated UChar* strings. Use together with
597 * uhash_hashUChars.
598 * @param key1 The string for comparison
599 * @param key2 The string for comparison
600 * @return true if key1 and key2 are equal, return false otherwise.
601 */
602 U_CAPI UBool U_EXPORT2
603 uhash_compareUChars(const UHashTok key1, const UHashTok key2);
604
605 /**
606 * Comparator for null-terminated char* strings. Use together with
607 * uhash_hashChars.
608 * @param key1 The string for comparison
609 * @param key2 The string for comparison
610 * @return true if key1 and key2 are equal, return false otherwise.
611 */
612 U_CAPI UBool U_EXPORT2
613 uhash_compareChars(const UHashTok key1, const UHashTok key2);
614
615 /**
616 * Case-insensitive comparator for null-terminated char* strings. Use
617 * together with uhash_hashIChars.
618 * @param key1 The string for comparison
619 * @param key2 The string for comparison
620 * @return true if key1 and key2 are equal, return false otherwise.
621 */
622 U_CAPI UBool U_EXPORT2
623 uhash_compareIChars(const UHashTok key1, const UHashTok key2);
624
625 /********************************************************************
626 * UnicodeString Support Functions
627 ********************************************************************/
628
629 /**
630 * Hash function for UnicodeString* keys.
631 * @param key The string (const char*) to hash.
632 * @return A hash code for the key.
633 */
634 U_CAPI int32_t U_EXPORT2
635 uhash_hashUnicodeString(const UHashTok key);
636
637 /**
638 * Hash function for UnicodeString* keys (case insensitive).
639 * Make sure to use together with uhash_compareCaselessUnicodeString.
640 * @param key The string (const char*) to hash.
641 * @return A hash code for the key.
642 */
643 U_CAPI int32_t U_EXPORT2
644 uhash_hashCaselessUnicodeString(const UHashTok key);
645
646 /**
647 * Comparator function for UnicodeString* keys.
648 * @param key1 The string for comparison
649 * @param key2 The string for comparison
650 * @return true if key1 and key2 are equal, return false otherwise.
651 */
652 U_CAPI UBool U_EXPORT2
653 uhash_compareUnicodeString(const UHashTok key1, const UHashTok key2);
654
655 /**
656 * Comparator function for UnicodeString* keys (case insensitive).
657 * Make sure to use together with uhash_hashCaselessUnicodeString.
658 * @param key1 The string for comparison
659 * @param key2 The string for comparison
660 * @return true if key1 and key2 are equal, return false otherwise.
661 */
662 U_CAPI UBool U_EXPORT2
663 uhash_compareCaselessUnicodeString(const UHashTok key1, const UHashTok key2);
664
665 /**
666 * Deleter function for UnicodeString* keys or values.
667 * @param obj The object to be deleted
668 */
669 U_CAPI void U_EXPORT2
670 uhash_deleteUnicodeString(void *obj);
671
672 /********************************************************************
673 * int32_t Support Functions
674 ********************************************************************/
675
676 /**
677 * Hash function for 32-bit integer keys.
678 * @param key The string (const char*) to hash.
679 * @return A hash code for the key.
680 */
681 U_CAPI int32_t U_EXPORT2
682 uhash_hashLong(const UHashTok key);
683
684 /**
685 * Comparator function for 32-bit integer keys.
686 * @param key1 The integer for comparison
687 * @param Key2 The integer for comparison
688 * @return true if key1 and key2 are equal, return false otherwise
689 */
690 U_CAPI UBool U_EXPORT2
691 uhash_compareLong(const UHashTok key1, const UHashTok key2);
692
693 /********************************************************************
694 * Other Support Functions
695 ********************************************************************/
696
697 /**
698 * Deleter for Hashtable objects.
699 * @param obj The object to be deleted
700 */
701 U_CAPI void U_EXPORT2
702 uhash_deleteHashtable(void *obj);
703
704 /**
705 * Deleter for UVector objects.
706 * @param obj The object to be deleted
707 */
708 U_CAPI void U_EXPORT2
709 uhash_deleteUVector(void *obj);
710
711 /**
712 * Deleter for any key or value allocated using uprv_malloc. Calls
713 * uprv_free.
714 * @param obj The object to be deleted
715 */
716 U_CAPI void U_EXPORT2
717 uhash_freeBlock(void *obj);
718
719 /**
720 * Checks if the given hash tables are equal or not.
721 * @param hash1
722 * @param hash2
723 * @return true if the hashtables are equal and false if not.
724 */
725 U_CAPI UBool U_EXPORT2
726 uhash_equals(const UHashtable* hash1, const UHashtable* hash2);
727
728 #endif