michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 1997-2011, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: * file name: uelement.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 2011jul04 michael@0: * created by: Markus W. Scherer michael@0: * michael@0: * Common definitions for UHashTable and UVector. michael@0: * UHashTok moved here from uhash.h and renamed UElement. michael@0: * This allows users of UVector to avoid the confusing #include of uhash.h. michael@0: * uhash.h aliases UElement to UHashTok, michael@0: * so that we need not change all of its code and its users. michael@0: */ michael@0: michael@0: #ifndef __UELEMENT_H__ michael@0: #define __UELEMENT_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: U_CDECL_BEGIN michael@0: michael@0: /** michael@0: * A UVector element, or a key or value within a UHashtable. michael@0: * It may be either a 32-bit integral value or an opaque void* pointer. michael@0: * The void* pointer may be smaller than 32 bits (e.g. 24 bits) michael@0: * or may be larger (e.g. 64 bits). michael@0: * michael@0: * Because a UElement is the size of a native pointer or a 32-bit michael@0: * integer, we pass it around by value. michael@0: */ michael@0: union UElement { michael@0: void* pointer; michael@0: int32_t integer; michael@0: }; michael@0: typedef union UElement UElement; michael@0: michael@0: /** michael@0: * An element-equality (boolean) comparison function. michael@0: * @param e1 An element (object or integer) michael@0: * @param e2 An element (object or integer) michael@0: * @return TRUE if the two elements are equal. michael@0: */ michael@0: typedef UBool U_CALLCONV UElementsAreEqual(const UElement e1, const UElement e2); michael@0: michael@0: /** michael@0: * An element sorting (three-way) comparison function. michael@0: * @param e1 An element (object or integer) michael@0: * @param e2 An element (object or integer) michael@0: * @return 0 if the two elements are equal, -1 if e1 is < e2, or +1 if e1 is > e2. michael@0: */ michael@0: typedef int8_t U_CALLCONV UElementComparator(UElement e1, UElement e2); michael@0: michael@0: /** michael@0: * An element assignment function. It may copy an integer, copy michael@0: * a pointer, or clone a pointer, as appropriate. michael@0: * @param dst The element to be assigned to michael@0: * @param src The element to assign from michael@0: */ michael@0: typedef void U_CALLCONV UElementAssigner(UElement *dst, UElement *src); michael@0: michael@0: U_CDECL_END michael@0: michael@0: /** michael@0: * Comparator function for UnicodeString* keys. Implements UElementsAreEqual. michael@0: * @param key1 The string for comparison michael@0: * @param key2 The string for comparison michael@0: * @return true if key1 and key2 are equal, return false otherwise. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: uhash_compareUnicodeString(const UElement key1, const UElement key2); michael@0: michael@0: /** michael@0: * Comparator function for UnicodeString* keys (case insensitive). michael@0: * Make sure to use together with uhash_hashCaselessUnicodeString. michael@0: * Implements UElementsAreEqual. michael@0: * @param key1 The string for comparison michael@0: * @param key2 The string for comparison michael@0: * @return true if key1 and key2 are equal, return false otherwise. michael@0: */ michael@0: U_CAPI UBool U_EXPORT2 michael@0: uhash_compareCaselessUnicodeString(const UElement key1, const UElement key2); michael@0: michael@0: #endif /* __UELEMENT_H__ */