| 1 |
// © 2016 and later: Unicode, Inc. and others. |
| 2 |
// License & terms of use: http://www.unicode.org/copyright.html |
| 3 |
/* |
| 4 |
******************************************************************************* |
| 5 |
* Copyright (C) 1997-2011, International Business Machines |
| 6 |
* Corporation and others. All Rights Reserved. |
| 7 |
******************************************************************************* |
| 8 |
* file name: uelement.h |
| 9 |
* encoding: UTF-8 |
| 10 |
* tab size: 8 (not used) |
| 11 |
* indentation:4 |
| 12 |
* |
| 13 |
* created on: 2011jul04 |
| 14 |
* created by: Markus W. Scherer |
| 15 |
* |
| 16 |
* Common definitions for UHashTable and UVector. |
| 17 |
* UHashTok moved here from uhash.h and renamed UElement. |
| 18 |
* This allows users of UVector to avoid the confusing #include of uhash.h. |
| 19 |
* uhash.h aliases UElement to UHashTok, |
| 20 |
* so that we need not change all of its code and its users. |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef __UELEMENT_H__ |
| 24 |
#define __UELEMENT_H__ |
| 25 |
|
| 26 |
#include "unicode/utypes.h" |
| 27 |
|
| 28 |
U_CDECL_BEGIN |
| 29 |
|
| 30 |
/** |
| 31 |
* A UVector element, or a key or value within a UHashtable. |
| 32 |
* It may be either a 32-bit integral value or an opaque void* pointer. |
| 33 |
* The void* pointer may be smaller than 32 bits (e.g. 24 bits) |
| 34 |
* or may be larger (e.g. 64 bits). |
| 35 |
* |
| 36 |
* Because a UElement is the size of a native pointer or a 32-bit |
| 37 |
* integer, we pass it around by value. |
| 38 |
*/ |
| 39 |
union UElement { |
| 40 |
void* pointer; |
| 41 |
int32_t integer; |
| 42 |
}; |
| 43 |
typedef union UElement UElement; |
| 44 |
|
| 45 |
/** |
| 46 |
* An element-equality (boolean) comparison function. |
| 47 |
* @param e1 An element (object or integer) |
| 48 |
* @param e2 An element (object or integer) |
| 49 |
* @return true if the two elements are equal. |
| 50 |
*/ |
| 51 |
typedef UBool U_CALLCONV UElementsAreEqual(const UElement e1, const UElement e2); |
| 52 |
|
| 53 |
/** |
| 54 |
* An element sorting (three-way) comparison function. |
| 55 |
* @param e1 An element (object or integer) |
| 56 |
* @param e2 An element (object or integer) |
| 57 |
* @return 32-bit signed integer comparison result: |
| 58 |
* ==0 if the two elements are equal, |
| 59 |
* <0 if e1 is < e2, or |
| 60 |
* >0 if e1 is > e2. |
| 61 |
*/ |
| 62 |
typedef int32_t U_CALLCONV UElementComparator(UElement e1, UElement e2); |
| 63 |
|
| 64 |
/** |
| 65 |
* An element assignment function. It may copy an integer, copy |
| 66 |
* a pointer, or clone a pointer, as appropriate. |
| 67 |
* @param dst The element to be assigned to |
| 68 |
* @param src The element to assign from |
| 69 |
*/ |
| 70 |
typedef void U_CALLCONV UElementAssigner(UElement *dst, UElement *src); |
| 71 |
|
| 72 |
U_CDECL_END |
| 73 |
|
| 74 |
/** |
| 75 |
* Comparator function for UnicodeString* keys. Implements UElementsAreEqual. |
| 76 |
* @param key1 The string for comparison |
| 77 |
* @param key2 The string for comparison |
| 78 |
* @return true if key1 and key2 are equal, return false otherwise. |
| 79 |
*/ |
| 80 |
U_CAPI UBool U_EXPORT2 |
| 81 |
uhash_compareUnicodeString(const UElement key1, const UElement key2); |
| 82 |
|
| 83 |
/** |
| 84 |
* Comparator function for UnicodeString* keys (case insensitive). |
| 85 |
* Make sure to use together with uhash_hashCaselessUnicodeString. |
| 86 |
* Implements UElementsAreEqual. |
| 87 |
* @param key1 The string for comparison |
| 88 |
* @param key2 The string for comparison |
| 89 |
* @return true if key1 and key2 are equal, return false otherwise. |
| 90 |
*/ |
| 91 |
U_CAPI UBool U_EXPORT2 |
| 92 |
uhash_compareCaselessUnicodeString(const UElement key1, const UElement key2); |
| 93 |
|
| 94 |
#endif /* __UELEMENT_H__ */ |