comparison modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/common/hash.h @ 11038:20a8447c71c6

8207159: Update ICU to version 62.1 Reviewed-by: mbilla, kcr, ghb
author arajkumar
date Fri, 24 Aug 2018 15:06:40 +0530
parents fee4ef5c87df
children
comparison
equal deleted inserted replaced
0:3fa694a9133e 1:0c04d48a5675
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
1 /* 3 /*
2 ****************************************************************************** 4 ******************************************************************************
3 * Copyright (C) 1997-2011, International Business Machines 5 * Copyright (C) 1997-2014, International Business Machines
4 * Corporation and others. All Rights Reserved. 6 * Corporation and others. All Rights Reserved.
5 ****************************************************************************** 7 ******************************************************************************
6 * Date Name Description 8 * Date Name Description
7 * 03/28/00 aliu Creation. 9 * 03/28/00 aliu Creation.
8 ****************************************************************************** 10 ******************************************************************************
29 UHashtable* hash; 31 UHashtable* hash;
30 UHashtable hashObj; 32 UHashtable hashObj;
31 33
32 inline void init(UHashFunction *keyHash, UKeyComparator *keyComp, UValueComparator *valueComp, UErrorCode& status); 34 inline void init(UHashFunction *keyHash, UKeyComparator *keyComp, UValueComparator *valueComp, UErrorCode& status);
33 35
36 inline void initSize(UHashFunction *keyHash, UKeyComparator *keyComp, UValueComparator *valueComp, int32_t size, UErrorCode& status);
37
34 public: 38 public:
35 /** 39 /**
36 * Construct a hashtable 40 * Construct a hashtable
37 * @param ignoreKeyCase If true, keys are case insensitive. 41 * @param ignoreKeyCase If true, keys are case insensitive.
38 * @param status Error code 42 * @param status Error code
39 */ 43 */
40 Hashtable(UBool ignoreKeyCase, UErrorCode& status); 44 Hashtable(UBool ignoreKeyCase, UErrorCode& status);
45
46 /**
47 * Construct a hashtable
48 * @param ignoreKeyCase If true, keys are case insensitive.
49 * @param size initial size allocation
50 * @param status Error code
51 */
52 Hashtable(UBool ignoreKeyCase, int32_t size, UErrorCode& status);
41 53
42 /** 54 /**
43 * Construct a hashtable 55 * Construct a hashtable
44 * @param keyComp Comparator for comparing the keys 56 * @param keyComp Comparator for comparing the keys
45 * @param valueComp Comparator for comparing the values 57 * @param valueComp Comparator for comparing the values
83 95
84 void removeAll(void); 96 void removeAll(void);
85 97
86 const UHashElement* find(const UnicodeString& key) const; 98 const UHashElement* find(const UnicodeString& key) const;
87 99
100 /**
101 * @param pos - must be UHASH_FIRST on first call, and untouched afterwards.
102 * @see uhash_nextElement
103 */
88 const UHashElement* nextElement(int32_t& pos) const; 104 const UHashElement* nextElement(int32_t& pos) const;
89 105
90 UKeyComparator* setKeyComparator(UKeyComparator*keyComp); 106 UKeyComparator* setKeyComparator(UKeyComparator*keyComp);
91 107
92 UValueComparator* setValueComparator(UValueComparator* valueComp); 108 UValueComparator* setValueComparator(UValueComparator* valueComp);
111 hash = &hashObj; 127 hash = &hashObj;
112 uhash_setKeyDeleter(hash, uprv_deleteUObject); 128 uhash_setKeyDeleter(hash, uprv_deleteUObject);
113 } 129 }
114 } 130 }
115 131
132 inline void Hashtable::initSize(UHashFunction *keyHash, UKeyComparator *keyComp,
133 UValueComparator *valueComp, int32_t size, UErrorCode& status) {
134 if (U_FAILURE(status)) {
135 return;
136 }
137 uhash_initSize(&hashObj, keyHash, keyComp, valueComp, size, &status);
138 if (U_SUCCESS(status)) {
139 hash = &hashObj;
140 uhash_setKeyDeleter(hash, uprv_deleteUObject);
141 }
142 }
143
116 inline Hashtable::Hashtable(UKeyComparator *keyComp, UValueComparator *valueComp, 144 inline Hashtable::Hashtable(UKeyComparator *keyComp, UValueComparator *valueComp,
117 UErrorCode& status) : hash(0) { 145 UErrorCode& status) : hash(0) {
118 init( uhash_hashUnicodeString, keyComp, valueComp, status); 146 init( uhash_hashUnicodeString, keyComp, valueComp, status);
119 } 147 }
148
120 inline Hashtable::Hashtable(UBool ignoreKeyCase, UErrorCode& status) 149 inline Hashtable::Hashtable(UBool ignoreKeyCase, UErrorCode& status)
121 : hash(0) 150 : hash(0)
122 { 151 {
123 init(ignoreKeyCase ? uhash_hashCaselessUnicodeString 152 init(ignoreKeyCase ? uhash_hashCaselessUnicodeString
124 : uhash_hashUnicodeString, 153 : uhash_hashUnicodeString,
126 : uhash_compareUnicodeString, 155 : uhash_compareUnicodeString,
127 NULL, 156 NULL,
128 status); 157 status);
129 } 158 }
130 159
160 inline Hashtable::Hashtable(UBool ignoreKeyCase, int32_t size, UErrorCode& status)
161 : hash(0)
162 {
163 initSize(ignoreKeyCase ? uhash_hashCaselessUnicodeString
164 : uhash_hashUnicodeString,
165 ignoreKeyCase ? uhash_compareCaselessUnicodeString
166 : uhash_compareUnicodeString,
167 NULL, size,
168 status);
169 }
170
131 inline Hashtable::Hashtable(UErrorCode& status) 171 inline Hashtable::Hashtable(UErrorCode& status)
132 : hash(0) 172 : hash(0)
133 { 173 {
134 init(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, status); 174 init(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, status);
135 } 175 }