Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: source/common/uhash.h

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/udata.cpp ('k') | source/common/uhash.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ****************************************************************************** 2 ******************************************************************************
3 * Copyright (C) 1997-2011, International Business Machines 3 * Copyright (C) 1997-2015, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ****************************************************************************** 5 ******************************************************************************
6 * Date Name Description 6 * Date Name Description
7 * 03/22/00 aliu Adapted from original C++ ICU Hashtable. 7 * 03/22/00 aliu Adapted from original C++ ICU Hashtable.
8 * 07/06/01 aliu Modified to support int32_t keys on 8 * 07/06/01 aliu Modified to support int32_t keys on
9 * platforms with sizeof(void*) < 32. 9 * platforms with sizeof(void*) < 32.
10 ****************************************************************************** 10 ******************************************************************************
11 */ 11 */
12 12
13 #ifndef UHASH_H 13 #ifndef UHASH_H
14 #define UHASH_H 14 #define UHASH_H
15 15
16 #include "unicode/utypes.h" 16 #include "unicode/utypes.h"
17 #include "cmemory.h" 17 #include "cmemory.h"
18 #include "uelement.h" 18 #include "uelement.h"
19 #include "unicode/localpointer.h"
19 20
20 /** 21 /**
21 * UHashtable stores key-value pairs and does moderately fast lookup 22 * UHashtable stores key-value pairs and does moderately fast lookup
22 * based on keys. It provides a good tradeoff between access time and 23 * based on keys. It provides a good tradeoff between access time and
23 * storage space. As elements are added to it, it grows to accomodate 24 * storage space. As elements are added to it, it grows to accomodate
24 * them. By default, the table never shrinks, even if all elements 25 * them. By default, the table never shrinks, even if all elements
25 * are removed from it. 26 * are removed from it.
26 * 27 *
27 * Keys and values are stored as void* pointers. These void* pointers 28 * Keys and values are stored as void* pointers. These void* pointers
28 * may be actual pointers to strings, objects, or any other structure 29 * may be actual pointers to strings, objects, or any other structure
(...skipping 21 matching lines...) Expand all
50 * value is passed to uhash_put(), this has the effect of doing a 51 * value is passed to uhash_put(), this has the effect of doing a
51 * uhash_remove() on that key. This keeps uhash_get(), uhash_count(), 52 * uhash_remove() on that key. This keeps uhash_get(), uhash_count(),
52 * and uhash_nextElement() consistent with one another. 53 * and uhash_nextElement() consistent with one another.
53 * 54 *
54 * To see everything in a hashtable, use uhash_nextElement() to 55 * To see everything in a hashtable, use uhash_nextElement() to
55 * iterate through its contents. Each call to this function returns a 56 * iterate through its contents. Each call to this function returns a
56 * UHashElement pointer. A hash element contains a key, value, and 57 * UHashElement pointer. A hash element contains a key, value, and
57 * hashcode. During iteration an element may be deleted by calling 58 * hashcode. During iteration an element may be deleted by calling
58 * uhash_removeElement(); iteration may safely continue thereafter. 59 * uhash_removeElement(); iteration may safely continue thereafter.
59 * The uhash_remove() function may also be safely called in 60 * The uhash_remove() function may also be safely called in
60 * mid-iteration. However, if uhash_put() is called during iteration 61 * mid-iteration. If uhash_put() is called during iteration,
61 * then the iteration will be out of sync. Under no circumstances 62 * the iteration is still guaranteed to terminate reasonably, but
62 * should the UHashElement returned by uhash_nextElement be modified 63 * there is no guarantee that every element will be returned or that
63 * directly. 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.
64 * 68 *
65 * By default, the hashtable grows when necessary, but never shrinks, 69 * By default, the hashtable grows when necessary, but never shrinks,
66 * even if all items are removed. For most applications this is 70 * even if all items are removed. For most applications this is
67 * optimal. However, in a highly dynamic usage where memory is at a 71 * optimal. However, in a highly dynamic usage where memory is at a
68 * premium, the table can be set to both grow and shrink by calling 72 * premium, the table can be set to both grow and shrink by calling
69 * uhash_setResizePolicy() with the policy U_GROW_AND_SHRINK. In a 73 * uhash_setResizePolicy() with the policy U_GROW_AND_SHRINK. In a
70 * situation where memory is critical and the client wants a table 74 * situation where memory is critical and the client wants a table
71 * that does not grow at all, the constant U_FIXED can be used. 75 * that does not grow at all, the constant U_FIXED can be used.
72 */ 76 */
73 77
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 * compare, then the hash key may be desired in order to obtain the 482 * compare, then the hash key may be desired in order to obtain the
479 * canonical case corresponding to a search key. 483 * canonical case corresponding to a search key.
480 * @param hash The target UHashtable. 484 * @param hash The target UHashtable.
481 * @param key A key stored in a hashtable 485 * @param key A key stored in a hashtable
482 * @return a hash element, or NULL if the key is not found. 486 * @return a hash element, or NULL if the key is not found.
483 */ 487 */
484 U_CAPI const UHashElement* U_EXPORT2 488 U_CAPI const UHashElement* U_EXPORT2
485 uhash_find(const UHashtable *hash, const void* key); 489 uhash_find(const UHashtable *hash, const void* key);
486 490
487 /** 491 /**
492 * \def UHASH_FIRST
493 * Constant for use with uhash_nextElement
494 * @see uhash_nextElement
495 */
496 #define UHASH_FIRST (-1)
497
498 /**
488 * Iterate through the elements of a UHashtable. The caller must not 499 * Iterate through the elements of a UHashtable. The caller must not
489 * modify the returned object. However, uhash_removeElement() may be 500 * modify the returned object. However, uhash_removeElement() may be
490 * called during iteration to remove an element from the table. 501 * called during iteration to remove an element from the table.
491 * Iteration may safely be resumed afterwards. If uhash_put() is 502 * Iteration may safely be resumed afterwards. If uhash_put() is
492 * called during iteration the iteration will then be out of sync and 503 * called during iteration the iteration will then be out of sync and
493 * should be restarted. 504 * should be restarted.
494 * @param hash The target UHashtable. 505 * @param hash The target UHashtable.
495 * @param pos This should be set to -1 initially, and left untouched 506 * @param pos This should be set to UHASH_FIRST initially, and left untouched
496 * thereafter. 507 * thereafter.
497 * @return a hash element, or NULL if no further key-value pairs 508 * @return a hash element, or NULL if no further key-value pairs
498 * exist in the table. 509 * exist in the table.
499 */ 510 */
500 U_CAPI const UHashElement* U_EXPORT2 511 U_CAPI const UHashElement* U_EXPORT2
501 uhash_nextElement(const UHashtable *hash, 512 uhash_nextElement(const UHashtable *hash,
502 int32_t *pos); 513 int32_t *pos);
503 514
504 /** 515 /**
505 * Remove an element, returned by uhash_nextElement(), from the table. 516 * Remove an element, returned by uhash_nextElement(), from the table.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 667
657 /** 668 /**
658 * Checks if the given hash tables are equal or not. 669 * Checks if the given hash tables are equal or not.
659 * @param hash1 670 * @param hash1
660 * @param hash2 671 * @param hash2
661 * @return true if the hashtables are equal and false if not. 672 * @return true if the hashtables are equal and false if not.
662 */ 673 */
663 U_CAPI UBool U_EXPORT2 674 U_CAPI UBool U_EXPORT2
664 uhash_equals(const UHashtable* hash1, const UHashtable* hash2); 675 uhash_equals(const UHashtable* hash1, const UHashtable* hash2);
665 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
666 #endif 695 #endif
696
697 #endif
OLDNEW
« no previous file with comments | « source/common/udata.cpp ('k') | source/common/uhash.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698