1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/uelement.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* Copyright (C) 1997-2011, International Business Machines 1.7 +* Corporation and others. All Rights Reserved. 1.8 +******************************************************************************* 1.9 +* file name: uelement.h 1.10 +* encoding: US-ASCII 1.11 +* tab size: 8 (not used) 1.12 +* indentation:4 1.13 +* 1.14 +* created on: 2011jul04 1.15 +* created by: Markus W. Scherer 1.16 +* 1.17 +* Common definitions for UHashTable and UVector. 1.18 +* UHashTok moved here from uhash.h and renamed UElement. 1.19 +* This allows users of UVector to avoid the confusing #include of uhash.h. 1.20 +* uhash.h aliases UElement to UHashTok, 1.21 +* so that we need not change all of its code and its users. 1.22 +*/ 1.23 + 1.24 +#ifndef __UELEMENT_H__ 1.25 +#define __UELEMENT_H__ 1.26 + 1.27 +#include "unicode/utypes.h" 1.28 + 1.29 +U_CDECL_BEGIN 1.30 + 1.31 +/** 1.32 + * A UVector element, or a key or value within a UHashtable. 1.33 + * It may be either a 32-bit integral value or an opaque void* pointer. 1.34 + * The void* pointer may be smaller than 32 bits (e.g. 24 bits) 1.35 + * or may be larger (e.g. 64 bits). 1.36 + * 1.37 + * Because a UElement is the size of a native pointer or a 32-bit 1.38 + * integer, we pass it around by value. 1.39 + */ 1.40 +union UElement { 1.41 + void* pointer; 1.42 + int32_t integer; 1.43 +}; 1.44 +typedef union UElement UElement; 1.45 + 1.46 +/** 1.47 + * An element-equality (boolean) comparison function. 1.48 + * @param e1 An element (object or integer) 1.49 + * @param e2 An element (object or integer) 1.50 + * @return TRUE if the two elements are equal. 1.51 + */ 1.52 +typedef UBool U_CALLCONV UElementsAreEqual(const UElement e1, const UElement e2); 1.53 + 1.54 +/** 1.55 + * An element sorting (three-way) comparison function. 1.56 + * @param e1 An element (object or integer) 1.57 + * @param e2 An element (object or integer) 1.58 + * @return 0 if the two elements are equal, -1 if e1 is < e2, or +1 if e1 is > e2. 1.59 + */ 1.60 +typedef int8_t U_CALLCONV UElementComparator(UElement e1, UElement e2); 1.61 + 1.62 +/** 1.63 + * An element assignment function. It may copy an integer, copy 1.64 + * a pointer, or clone a pointer, as appropriate. 1.65 + * @param dst The element to be assigned to 1.66 + * @param src The element to assign from 1.67 + */ 1.68 +typedef void U_CALLCONV UElementAssigner(UElement *dst, UElement *src); 1.69 + 1.70 +U_CDECL_END 1.71 + 1.72 +/** 1.73 + * Comparator function for UnicodeString* keys. Implements UElementsAreEqual. 1.74 + * @param key1 The string for comparison 1.75 + * @param key2 The string for comparison 1.76 + * @return true if key1 and key2 are equal, return false otherwise. 1.77 + */ 1.78 +U_CAPI UBool U_EXPORT2 1.79 +uhash_compareUnicodeString(const UElement key1, const UElement key2); 1.80 + 1.81 +/** 1.82 + * Comparator function for UnicodeString* keys (case insensitive). 1.83 + * Make sure to use together with uhash_hashCaselessUnicodeString. 1.84 + * Implements UElementsAreEqual. 1.85 + * @param key1 The string for comparison 1.86 + * @param key2 The string for comparison 1.87 + * @return true if key1 and key2 are equal, return false otherwise. 1.88 + */ 1.89 +U_CAPI UBool U_EXPORT2 1.90 +uhash_compareCaselessUnicodeString(const UElement key1, const UElement key2); 1.91 + 1.92 +#endif /* __UELEMENT_H__ */