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