</Command>\r
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
</CustomBuild>\r
+ <ClInclude Include="uelement.h" />\r
<ClInclude Include="uenumimp.h" />\r
<ClInclude Include="uhash.h" />\r
<ClInclude Include="ulist.h" />\r
<ClInclude Include="uarrsort.h">\r
<Filter>collections</Filter>\r
</ClInclude>\r
+ <ClInclude Include="uelement.h">\r
+ <Filter>collections</Filter>\r
+ </ClInclude>\r
<ClInclude Include="uenumimp.h">\r
<Filter>collections</Filter>\r
</ClInclude>\r
#include "cstring.h"
#include "uhash.h"
#include "ucln_cmn.h"
+#include "ustr_imp.h"
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
int32_t
Locale::hashCode() const
{
- UHashTok hashKey;
- hashKey.pointer = fullName;
- return uhash_hashChars(hashKey);
+ return ustr_hashCharsN(fullName, uprv_strlen(fullName));
}
void
--- /dev/null
+/*
+*******************************************************************************
+* Copyright (C) 1997-2011, International Business Machines
+* Corporation and others. All Rights Reserved.
+*******************************************************************************
+* file name: uelement.h
+* encoding: US-ASCII
+* tab size: 8 (not used)
+* indentation:4
+*
+* created on: 2011jul04
+* created by: Markus W. Scherer
+*
+* Common definitions for UHashTable and UVector.
+* UHashTok moved here from uhash.h and renamed UElement.
+* This allows users of UVector to avoid the confusing #include of uhash.h.
+* uhash.h aliases UElement to UHashTok,
+* so that we need not change all of its code and its users.
+*/
+
+#ifndef __UELEMENT_H__
+#define __UELEMENT_H__
+
+#include "unicode/utypes.h"
+
+/**
+ * A UVector element, or a key or value within a UHashtable.
+ * It may be either a 32-bit integral value or an opaque void* pointer.
+ * The void* pointer may be smaller than 32 bits (e.g. 24 bits)
+ * or may be larger (e.g. 64 bits).
+ *
+ * Because a UElement is the size of a native pointer or a 32-bit
+ * integer, we pass it around by value.
+ */
+union UElement {
+ void* pointer;
+ int32_t integer;
+};
+typedef union UElement UElement;
+
+/**
+ * An element-equality (boolean) comparison function.
+ * @param e1 An element (object or integer)
+ * @param e2 An element (object or integer)
+ * @return TRUE if the two elements are equal.
+ */
+typedef UBool U_CALLCONV UElementsAreEqual(const UElement e1, const UElement e2);
+
+/**
+ * An element sorting (three-way) comparison function.
+ * @param e1 An element (object or integer)
+ * @param e2 An element (object or integer)
+ * @return 0 if the two elements are equal, -1 if e1 is < e2, or +1 if e1 is > e2.
+ */
+typedef int8_t U_CALLCONV UElementComparator(UElement e1, UElement e2);
+
+/**
+ * An element assignment function. It may copy an integer, copy
+ * a pointer, or clone a pointer, as appropriate.
+ * @param dst The element to be assigned to
+ * @param src The element to assign from
+ */
+typedef void U_CALLCONV UElementAssigner(UElement *dst, UElement *src);
+
+/**
+ * Comparator function for UnicodeString* keys. Implements UElementsAreEqual.
+ * @param key1 The string for comparison
+ * @param key2 The string for comparison
+ * @return true if key1 and key2 are equal, return false otherwise.
+ */
+U_CAPI UBool U_EXPORT2
+uhash_compareUnicodeString(const UElement key1, const UElement key2);
+
+/**
+ * Comparator function for UnicodeString* keys (case insensitive).
+ * Make sure to use together with uhash_hashCaselessUnicodeString.
+ * Implements UElementsAreEqual.
+ * @param key1 The string for comparison
+ * @param key2 The string for comparison
+ * @return true if key1 and key2 are equal, return false otherwise.
+ */
+U_CAPI UBool U_EXPORT2
+uhash_compareCaselessUnicodeString(const UElement key1, const UElement key2);
+
+#endif /* __UELEMENT_H__ */
#include "unicode/utypes.h"
#include "cmemory.h"
+#include "uelement.h"
/**
* UHashtable stores key-value pairs and does moderately fast lookup
U_CDECL_BEGIN
/**
- * A key or value within the hashtable. It may be either a 32-bit
- * integral value or an opaque void* pointer. The void* pointer may
- * be smaller than 32 bits (e.g. 24 bits) or may be larger (e.g. 64
- * bits). The hashing and comparison functions take a pointer to a
+ * A key or value within a UHashtable.
+ * The hashing and comparison functions take a pointer to a
* UHashTok, but the deleter receives the void* pointer within it.
- *
- * Because a UHashTok is the size of a native pointer or a 32-bit
- * integer, we pass it around by value.
*/
-union UHashTok {
- void* pointer;
- int32_t integer;
-};
-typedef union UHashTok UHashTok;
+typedef UElement UHashTok;
/**
* This is a single hash element.
typedef int32_t U_CALLCONV UHashFunction(const UHashTok key);
/**
- * A key comparison function.
- * @param key1 A key stored in a hashtable
- * @param key2 A key stored in a hashtable
- * @return TRUE if the two keys are equal.
+ * A key equality (boolean) comparison function.
*/
-typedef UBool U_CALLCONV UKeyComparator(const UHashTok key1,
- const UHashTok key2);
+typedef UElementsAreEqual UKeyComparator;
+
/**
- * A key comparison function.
- * @param val1 A key stored in a hashtable
- * @param val2 A key stored in a hashtable
- * @return TRUE if the two keys are equal.
+ * A value equality (boolean) comparison function.
*/
-typedef UBool U_CALLCONV UValueComparator(const UHashTok val1,
- const UHashTok val2);
+typedef UElementsAreEqual UValueComparator;
/* see cmemory.h for UObjectDeleter and uprv_deleteUObject() */
* @return A hash code for the key.
*/
U_CAPI int32_t U_EXPORT2
-uhash_hashUnicodeString(const UHashTok key);
+uhash_hashUnicodeString(const UElement key);
/**
* Hash function for UnicodeString* keys (case insensitive).
* @return A hash code for the key.
*/
U_CAPI int32_t U_EXPORT2
-uhash_hashCaselessUnicodeString(const UHashTok key);
-
-/**
- * Comparator function for UnicodeString* keys.
- * @param key1 The string for comparison
- * @param key2 The string for comparison
- * @return true if key1 and key2 are equal, return false otherwise.
- */
-U_CAPI UBool U_EXPORT2
-uhash_compareUnicodeString(const UHashTok key1, const UHashTok key2);
-
-/**
- * Comparator function for UnicodeString* keys (case insensitive).
- * Make sure to use together with uhash_hashCaselessUnicodeString.
- * @param key1 The string for comparison
- * @param key2 The string for comparison
- * @return true if key1 and key2 are equal, return false otherwise.
- */
-U_CAPI UBool U_EXPORT2
-uhash_compareCaselessUnicodeString(const UHashTok key1, const UHashTok key2);
+uhash_hashCaselessUnicodeString(const UElement key);
/********************************************************************
* int32_t Support Functions
#include "cmemory.h"
#include "cstring.h"
#include "patternprops.h"
-#include "uhash.h"
+#include "uelement.h"
#include "util.h"
#include "uvector.h"
#include "charstr.h"
#include "ustrfmt.h"
#include "uassert.h"
-#include "hash.h"
#include "bmpset.h"
#include "unisetspan.h"
// UnicodeString in UVector support
//----------------------------------------------------------------
-static void U_CALLCONV cloneUnicodeString(UHashTok *dst, UHashTok *src) {
+static void U_CALLCONV cloneUnicodeString(UElement *dst, UElement *src) {
dst->pointer = new UnicodeString(*(UnicodeString*)src->pointer);
}
-static int8_t U_CALLCONV compareUnicodeString(UHashTok t1, UHashTok t2) {
+static int8_t U_CALLCONV compareUnicodeString(UElement t1, UElement t2) {
const UnicodeString &a = *(const UnicodeString*)t1.pointer;
const UnicodeString &b = *(const UnicodeString*)t2.pointer;
return a.compare(b);
#include "cmemory.h"
#include "unicode/ustring.h"
#include "unicode/unistr.h"
-#include "uhash.h"
+#include "uelement.h"
#include "ustr_imp.h"
#include "umutex.h"
U_NAMESPACE_USE
U_CAPI int32_t U_EXPORT2
-uhash_hashUnicodeString(const UHashTok key) {
+uhash_hashUnicodeString(const UElement key) {
const UnicodeString *str = (const UnicodeString*) key.pointer;
return (str == NULL) ? 0 : str->hashCode();
}
// Moved here from uhash_us.cpp so that using a UVector of UnicodeString*
// does not depend on hashtable code.
U_CAPI UBool U_EXPORT2
-uhash_compareUnicodeString(const UHashTok key1, const UHashTok key2) {
+uhash_compareUnicodeString(const UElement key1, const UElement key2) {
const UnicodeString *str1 = (const UnicodeString*) key1.pointer;
const UnicodeString *str2 = (const UnicodeString*) key2.pointer;
if (str1 == str2) {
#include "unicode/ustring.h"
#include "unicode/unistr.h"
#include "unicode/uchar.h"
+#include "uelement.h"
#include "ustr_imp.h"
-#include "uhash.h"
U_NAMESPACE_BEGIN
// Defined here to reduce dependencies on break iterator
U_CAPI int32_t U_EXPORT2
-uhash_hashCaselessUnicodeString(const UHashTok key) {
+uhash_hashCaselessUnicodeString(const UElement key) {
U_NAMESPACE_USE
const UnicodeString *str = (const UnicodeString*) key.pointer;
if (str == NULL) {
// Defined here to reduce dependencies on break iterator
U_CAPI UBool U_EXPORT2
-uhash_compareCaselessUnicodeString(const UHashTok key1, const UHashTok key2) {
+uhash_compareCaselessUnicodeString(const UElement key1, const UElement key2) {
U_NAMESPACE_USE
const UnicodeString *str1 = (const UnicodeString*) key1.pointer;
const UnicodeString *str2 = (const UnicodeString*) key2.pointer;
/*
**********************************************************************
-* Copyright (C) 2003-2004, International Business Machines
+* Copyright (C) 2003-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
{
}
-UStack::UStack(UObjectDeleter *d, UKeyComparator *c, UErrorCode &status) :
+UStack::UStack(UObjectDeleter *d, UElementsAreEqual *c, UErrorCode &status) :
UVector(d, c, status)
{
}
-UStack::UStack(UObjectDeleter *d, UKeyComparator *c, int32_t initialCapacity, UErrorCode &status) :
+UStack::UStack(UObjectDeleter *d, UElementsAreEqual *c, int32_t initialCapacity, UErrorCode &status) :
UVector(d, c, initialCapacity, status)
{
}
#include "uvector.h"
#include "cmemory.h"
#include "uarrsort.h"
+#include "uelement.h"
U_NAMESPACE_BEGIN
_init(initialCapacity, status);
}
-UVector::UVector(UObjectDeleter *d, UKeyComparator *c, UErrorCode &status) :
+UVector::UVector(UObjectDeleter *d, UElementsAreEqual *c, UErrorCode &status) :
count(0),
capacity(0),
elements(0),
_init(DEFAULT_CAPACITY, status);
}
-UVector::UVector(UObjectDeleter *d, UKeyComparator *c, int32_t initialCapacity, UErrorCode &status) :
+UVector::UVector(UObjectDeleter *d, UElementsAreEqual *c, int32_t initialCapacity, UErrorCode &status) :
count(0),
capacity(0),
elements(0),
return;
}
// Fix bogus initialCapacity values; avoid malloc(0) and integer overflow
- if ((initialCapacity < 1) || (initialCapacity > (int32_t)(INT32_MAX / sizeof(UHashTok)))) {
+ if ((initialCapacity < 1) || (initialCapacity > (int32_t)(INT32_MAX / sizeof(UElement)))) {
initialCapacity = DEFAULT_CAPACITY;
}
- elements = (UHashTok *)uprv_malloc(sizeof(UHashTok)*initialCapacity);
+ elements = (UElement *)uprv_malloc(sizeof(UElement)*initialCapacity);
if (elements == 0) {
status = U_MEMORY_ALLOCATION_ERROR;
} else {
* Assign this object to another (make this a copy of 'other').
* Use the 'assign' function to assign each element.
*/
-void UVector::assign(const UVector& other, UTokenAssigner *assign, UErrorCode &ec) {
+void UVector::assign(const UVector& other, UElementAssigner *assign, UErrorCode &ec) {
if (ensureCapacity(other.count, ec)) {
setSize(other.count, ec);
if (U_SUCCESS(ec)) {
}
}
} else {
- UHashTok key;
+ UElement key;
for (i=0; i<count; i++) {
key.pointer = &other.elements[i];
if (!(*comparer)(key, elements[i])) {
int32_t UVector::indexOf(void* obj, int32_t startIndex) const {
- UHashTok key;
+ UElement key;
key.pointer = obj;
return indexOf(key, startIndex, HINT_KEY_POINTER);
}
int32_t UVector::indexOf(int32_t obj, int32_t startIndex) const {
- UHashTok key;
+ UElement key;
key.integer = obj;
return indexOf(key, startIndex, HINT_KEY_INTEGER);
}
// This only works if this object has a non-null comparer
-int32_t UVector::indexOf(UHashTok key, int32_t startIndex, int8_t hint) const {
+int32_t UVector::indexOf(UElement key, int32_t startIndex, int8_t hint) const {
int32_t i;
if (comparer != 0) {
for (i=startIndex; i<count; ++i) {
if (newCap < minimumCapacity) {
newCap = minimumCapacity;
}
- if (newCap > (int32_t)(INT32_MAX / sizeof(UHashTok))) { // integer overflow check
+ if (newCap > (int32_t)(INT32_MAX / sizeof(UElement))) { // integer overflow check
// We keep the original memory contents on bad minimumCapacity.
status = U_ILLEGAL_ARGUMENT_ERROR;
return FALSE;
}
- UHashTok* newElems = (UHashTok *)uprv_realloc(elements, sizeof(UHashTok)*newCap);
+ UElement* newElems = (UElement *)uprv_realloc(elements, sizeof(UElement)*newCap);
if (newElems == NULL) {
// We keep the original contents on the memory failure on realloc or bad minimumCapacity.
status = U_MEMORY_ALLOCATION_ERROR;
if (!ensureCapacity(newSize, status)) {
return;
}
- UHashTok empty;
+ UElement empty;
empty.pointer = NULL;
empty.integer = 0;
for (i=count; i<newSize; ++i) {
return old;
}
-UKeyComparator *UVector::setComparer(UKeyComparator *d) {
- UKeyComparator *old = comparer;
+UElementsAreEqual *UVector::setComparer(UElementsAreEqual *d) {
+ UElementsAreEqual *old = comparer;
comparer = d;
return old;
}
* as defined by 'compare'. The current elements are assumed to
* be sorted already.
*/
-void UVector::sortedInsert(void* obj, USortComparator *compare, UErrorCode& ec) {
- UHashTok tok;
- tok.pointer = obj;
- sortedInsert(tok, compare, ec);
+void UVector::sortedInsert(void* obj, UElementComparator *compare, UErrorCode& ec) {
+ UElement e;
+ e.pointer = obj;
+ sortedInsert(e, compare, ec);
}
/**
* as defined by 'compare'. The current elements are assumed to
* be sorted already.
*/
-void UVector::sortedInsert(int32_t obj, USortComparator *compare, UErrorCode& ec) {
- UHashTok tok;
- tok.integer = obj;
- sortedInsert(tok, compare, ec);
+void UVector::sortedInsert(int32_t obj, UElementComparator *compare, UErrorCode& ec) {
+ UElement e;
+ e.integer = obj;
+ sortedInsert(e, compare, ec);
}
// ASSUME elements[] IS CURRENTLY SORTED
-void UVector::sortedInsert(UHashTok tok, USortComparator *compare, UErrorCode& ec) {
+void UVector::sortedInsert(UElement e, UElementComparator *compare, UErrorCode& ec) {
// Perform a binary search for the location to insert tok at. Tok
// will be inserted between two elements a and b such that a <=
// tok && tok < b, where there is a 'virtual' elements[-1] always
int32_t min = 0, max = count;
while (min != max) {
int32_t probe = (min + max) / 2;
- int8_t c = (*compare)(elements[probe], tok);
+ int8_t c = (*compare)(elements[probe], e);
if (c > 0) {
max = probe;
} else {
for (int32_t i=count; i>min; --i) {
elements[i] = elements[i-1];
}
- elements[min] = tok;
+ elements[min] = e;
++count;
}
}
*/
static int32_t U_CALLCONV
sortComparator(const void *context, const void *left, const void *right) {
- USortComparator *compare = *static_cast<USortComparator * const *>(context);
- UHashTok tok1 = *static_cast<const UHashTok *>(left);
- UHashTok tok2 = *static_cast<const UHashTok *>(right);
- int32_t result = (*compare)(tok1, tok2);
+ UElementComparator *compare = *static_cast<UElementComparator * const *>(context);
+ UElement e1 = *static_cast<const UElement *>(left);
+ UElement e2 = *static_cast<const UElement *>(right);
+ int32_t result = (*compare)(e1, e2);
return result;
}
*/
static int32_t U_CALLCONV
sortiComparator(const void * /*context */, const void *left, const void *right) {
- const UHashTok *tok1 = static_cast<const UHashTok *>(left);
- const UHashTok *tok2 = static_cast<const UHashTok *>(right);
- int32_t result = tok1->integer < tok2->integer? -1 :
- tok1->integer == tok2->integer? 0 : 1;
+ const UElement *e1 = static_cast<const UElement *>(left);
+ const UElement *e2 = static_cast<const UElement *>(right);
+ int32_t result = e1->integer < e2->integer? -1 :
+ e1->integer == e2->integer? 0 : 1;
return result;
}
/**
* Sort the vector, assuming it constains ints.
* (A more general sort would take a comparison function, but it's
- * not clear whether UVector's USortComparator or
+ * not clear whether UVector's UElementComparator or
* UComparator from uprv_sortAray would be more appropriate.)
*/
void UVector::sorti(UErrorCode &ec) {
if (U_SUCCESS(ec)) {
- uprv_sortArray(elements, count, sizeof(UHashTok),
+ uprv_sortArray(elements, count, sizeof(UElement),
sortiComparator, NULL, FALSE, &ec);
}
}
* as a (void *) data pointer, so instead we pass a (data) pointer to a
* pointer-to-function variable.
*/
-void UVector::sort(USortComparator *compare, UErrorCode &ec) {
+void UVector::sort(UElementComparator *compare, UErrorCode &ec) {
if (U_SUCCESS(ec)) {
- uprv_sortArray(elements, count, sizeof(UHashTok),
+ uprv_sortArray(elements, count, sizeof(UElement),
sortComparator, &compare, FALSE, &ec);
}
}
*/
void UVector::sortWithUComparator(UComparator *compare, const void *context, UErrorCode &ec) {
if (U_SUCCESS(ec)) {
- uprv_sortArray(elements, count, sizeof(UHashTok),
+ uprv_sortArray(elements, count, sizeof(UElement),
compare, context, FALSE, &ec);
}
}
#include "unicode/utypes.h"
#include "unicode/uobject.h"
+#include "cmemory.h"
#include "uarrsort.h"
-#include "uhash.h"
+#include "uelement.h"
U_NAMESPACE_BEGIN
-/**
- * A token comparison function.
- * @param tok1 A token (object or integer)
- * @param tok2 A token (object or integer)
- * @return 0 if the two tokens are equal, -1 if tok1 is < tok2, or
- * +1 if tok1 is > tok2.
- */
-typedef int8_t U_CALLCONV USortComparator(UHashTok tok1,
- UHashTok tok2);
-
-/**
- * A token assignment function. It may copy an integer, copy
- * a pointer, or clone a pointer, as appropriate.
- * @param dst The token to be assigned to
- * @param src The token to assign from
- */
-typedef void U_CALLCONV UTokenAssigner(UHashTok *dst,
- UHashTok *src);
-
/**
* <p>Ultralightweight C++ implementation of a <tt>void*</tt> vector
* that is (mostly) compatible with java.util.Vector.
*/
class U_COMMON_API UVector : public UObject {
// NOTE: UVector uses the UHashKey (union of void* and int32_t) as
- // its basic storage type. It uses UKeyComparator as its
+ // its basic storage type. It uses UElementsAreEqual as its
// comparison function. It uses UObjectDeleter as its deleter
// function. These are named for hashtables, but used here as-is
// rather than duplicating the type. This allows sharing of
int32_t capacity;
- UHashTok* elements;
+ UElement* elements;
UObjectDeleter *deleter;
- UKeyComparator *comparer;
+ UElementsAreEqual *comparer;
public:
UVector(UErrorCode &status);
UVector(int32_t initialCapacity, UErrorCode &status);
- UVector(UObjectDeleter *d, UKeyComparator *c, UErrorCode &status);
+ UVector(UObjectDeleter *d, UElementsAreEqual *c, UErrorCode &status);
- UVector(UObjectDeleter *d, UKeyComparator *c, int32_t initialCapacity, UErrorCode &status);
+ UVector(UObjectDeleter *d, UElementsAreEqual *c, int32_t initialCapacity, UErrorCode &status);
virtual ~UVector();
* Assign this object to another (make this a copy of 'other').
* Use the 'assign' function to assign each element.
*/
- void assign(const UVector& other, UTokenAssigner *assign, UErrorCode &ec);
+ void assign(const UVector& other, UElementAssigner *assign, UErrorCode &ec);
/**
* Compare this vector with another. They will be considered
UObjectDeleter *setDeleter(UObjectDeleter *d);
- UKeyComparator *setComparer(UKeyComparator *c);
+ UElementsAreEqual *setComparer(UElementsAreEqual *c);
void* operator[](int32_t index) const;
* as defined by 'compare'. The current elements are assumed to
* be sorted already.
*/
- void sortedInsert(void* obj, USortComparator *compare, UErrorCode& ec);
+ void sortedInsert(void* obj, UElementComparator *compare, UErrorCode& ec);
/**
* Insert the given integer into this vector at its sorted position
* as defined by 'compare'. The current elements are assumed to
* be sorted already.
*/
- void sortedInsert(int32_t obj, USortComparator *compare, UErrorCode& ec);
+ void sortedInsert(int32_t obj, UElementComparator *compare, UErrorCode& ec);
/**
* Sort the contents of the vector, assuming that the contents of the
/**
* Sort the contents of this vector, using a caller-supplied function
* to do the comparisons. (It's confusing that
- * UVector's USortComparator function is different from the
+ * UVector's UElementComparator function is different from the
* UComparator function type defined in uarrsort.h)
*/
- void sort(USortComparator *compare, UErrorCode &ec);
+ void sort(UElementComparator *compare, UErrorCode &ec);
/**
* Sort the contents of this vector using a caller-supplied function
private:
void _init(int32_t initialCapacity, UErrorCode &status);
- int32_t indexOf(UHashTok key, int32_t startIndex = 0, int8_t hint = 0) const;
+ int32_t indexOf(UElement key, int32_t startIndex = 0, int8_t hint = 0) const;
- void sortedInsert(UHashTok tok, USortComparator *compare, UErrorCode& ec);
+ void sortedInsert(UElement e, UElementComparator *compare, UErrorCode& ec);
// Disallow
UVector(const UVector&);
UStack(int32_t initialCapacity, UErrorCode &status);
- UStack(UObjectDeleter *d, UKeyComparator *c, UErrorCode &status);
+ UStack(UObjectDeleter *d, UElementsAreEqual *c, UErrorCode &status);
- UStack(UObjectDeleter *d, UKeyComparator *c, int32_t initialCapacity, UErrorCode &status);
+ UStack(UObjectDeleter *d, UElementsAreEqual *c, int32_t initialCapacity, UErrorCode &status);
virtual ~UStack();
//
static int32_t U_CALLCONV
sortCollateComparator(const void *context, const void *left, const void *right) {
- const UHashTok *leftTok = static_cast<const UHashTok *>(left);
- const UHashTok *rightTok = static_cast<const UHashTok *>(right);
- const UnicodeString *leftString = static_cast<const UnicodeString *>(leftTok->pointer);
- const UnicodeString *rightString = static_cast<const UnicodeString *>(rightTok->pointer);
+ const UElement *leftElement = static_cast<const UElement *>(left);
+ const UElement *rightElement = static_cast<const UElement *>(right);
+ const UnicodeString *leftString = static_cast<const UnicodeString *>(leftElement->pointer);
+ const UnicodeString *rightString = static_cast<const UnicodeString *>(rightElement->pointer);
const Collator *col = static_cast<const Collator *>(context);
if (leftString == rightString) {
//
static int32_t U_CALLCONV
recordCompareFn(const void *context, const void *left, const void *right) {
- const UHashTok *leftTok = static_cast<const UHashTok *>(left);
- const UHashTok *rightTok = static_cast<const UHashTok *>(right);
- const AlphabeticIndex::Record *leftRec = static_cast<const AlphabeticIndex::Record *>(leftTok->pointer);
- const AlphabeticIndex::Record *rightRec = static_cast<const AlphabeticIndex::Record *>(rightTok->pointer);
+ const UElement *leftElement = static_cast<const UElement *>(left);
+ const UElement *rightElement = static_cast<const UElement *>(right);
+ const AlphabeticIndex::Record *leftRec = static_cast<const AlphabeticIndex::Record *>(leftElement->pointer);
+ const AlphabeticIndex::Record *rightRec = static_cast<const AlphabeticIndex::Record *>(rightElement->pointer);
const Collator *col = static_cast<const Collator *>(context);
Collator::EComparisonResult r = col->compare(leftRec->sortingName_, rightRec->sortingName_);
*
* For use with array sort or UVector.
* @param context A UErrorCode pointer.
- * @param left A UHashTok pointer, which must refer to a UnicodeString *
- * @param right A UHashTok pointer, which must refer to a UnicodeString *
+ * @param left A UElement pointer, which must refer to a UnicodeString *
+ * @param right A UElement pointer, which must refer to a UnicodeString *
*/
static int32_t U_CALLCONV
PreferenceComparator(const void *context, const void *left, const void *right) {
- const UHashTok *leftTok = static_cast<const UHashTok *>(left);
- const UHashTok *rightTok = static_cast<const UHashTok *>(right);
- const UnicodeString *s1 = static_cast<const UnicodeString *>(leftTok->pointer);
- const UnicodeString *s2 = static_cast<const UnicodeString *>(rightTok->pointer);
+ const UElement *leftElement = static_cast<const UElement *>(left);
+ const UElement *rightElement = static_cast<const UElement *>(right);
+ const UnicodeString *s1 = static_cast<const UnicodeString *>(leftElement->pointer);
+ const UnicodeString *s2 = static_cast<const UnicodeString *>(rightElement->pointer);
UErrorCode &status = *(UErrorCode *)(context); // Cast off both static and const.
if (s1 == s2) {
return 0;
#include "messageimpl.h"
#include "msgfmt_impl.h"
#include "uassert.h"
+#include "uelement.h"
+#include "uhash.h"
#include "ustrfmt.h"
#include "util.h"
#include "uvector.h"
#include "unicode/sortkey.h"
#include "cmemory.h"
-#include "uhash.h"
+#include "uelement.h"
+#include "ustr_imp.h"
U_NAMESPACE_BEGIN
if (fHashCode == kInvalidHashCode)
{
- UHashTok key;
- key.pointer = fBytes;
- ((CollationKey *)this)->fHashCode = uhash_hashChars(key);
+ const char *s = reinterpret_cast<const char *>(fBytes);
+ ((CollationKey *)this)->fHashCode = s == NULL ? 0 : ustr_hashCharsN(s, fCount);
#if 0
// We compute the hash by iterating sparsely over 64 (at most) characters
// spaced evenly through the string. For each character, we multiply the
#include "unicode/unistr.h"
-union UHashTok;
-
U_NAMESPACE_BEGIN
class Locale;
#include "unicode/fpositer.h"
#include "unicode/stringpiece.h"
-union UHashTok;
-
U_NAMESPACE_BEGIN
class DigitList;
/*
*******************************************************************************
- * Copyright (C) 2008-2010, International Business Machines Corporation and
+ * Copyright (C) 2008-2011, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*
#include "unicode/locid.h"
#include "unicode/ucal.h"
#include "unicode/dtptngen.h"
-//#include "dtitv_impl.h"
-
-/**
- * @internal ICU 4.0
- */
-
-union UHashTok;
-
U_NAMESPACE_BEGIN
#include "unicode/numfmt.h"
#include "unicode/plurrule.h"
-/**
- * @internal ICU 4.2
- */
-
-union UHashTok;
-
/**
* Constants for various styles.
* There are 2 styles: full name and abbreviated name.
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 2004-2010, International Business Machines Corporation and
+ * Copyright (c) 2004-2011, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
#include "intltest.h"
#include "uvectest.h"
-#include "uvector.h"
-#include "hash.h"
-
#include "cstring.h"
+#include "hash.h"
+#include "uelement.h"
+#include "uvector.h"
//---------------------------------------------------------------------------
//
}
static int8_t U_CALLCONV
-UVectorTest_compareInt32(UHashTok key1, UHashTok key2) {
+UVectorTest_compareInt32(UElement key1, UElement key2) {
if (key1.integer > key2.integer) {
return 1;
}
U_CDECL_BEGIN
static int8_t U_CALLCONV
-UVectorTest_compareCstrings(const UHashTok key1, const UHashTok key2) {
+UVectorTest_compareCstrings(const UElement key1, const UElement key2) {
return !strcmp((const char *)key1.pointer, (const char *)key2.pointer);
}
U_CDECL_END
}
U_CDECL_BEGIN
-static UBool U_CALLCONV neverTRUE(const UHashTok /*key1*/, const UHashTok /*key2*/) {
+static UBool U_CALLCONV neverTRUE(const UElement /*key1*/, const UElement /*key2*/) {
return FALSE;
}
#include "errmsg.h"
#include "uarrsort.h"
+#include "uelement.h"
#include "uinvchar.h"
#include "ustr_imp.h"
}
static int32_t U_CALLCONV
-string_hash(const UHashTok key) {
+string_hash(const UElement key) {
const struct SResource *res = (struct SResource *)key.pointer;
return ustr_hashUCharsN(res->u.fString.fChars, res->u.fString.fLength);
}
static UBool U_CALLCONV
-string_comp(const UHashTok key1, const UHashTok key2) {
+string_comp(const UElement key1, const UElement key2) {
const struct SResource *res1 = (struct SResource *)key1.pointer;
const struct SResource *res2 = (struct SResource *)key2.pointer;
return 0 == u_strCompare(res1->u.fString.fChars, res1->u.fString.fLength,