X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/2ca993e82fb37b597a3c73ecd1586a139a6579c5..HEAD:/icuSources/common/uhash.h diff --git a/icuSources/common/uhash.h b/icuSources/common/uhash.h index 0d96ea34..e423454c 100644 --- a/icuSources/common/uhash.h +++ b/icuSources/common/uhash.h @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ****************************************************************************** -* Copyright (C) 1997-2016, International Business Machines +* Copyright (C) 1997-2015, International Business Machines * Corporation and others. All Rights Reserved. ****************************************************************************** * Date Name Description @@ -152,7 +154,7 @@ struct UHashtable { * If NULL won't do anything */ /* Size parameters */ - + int32_t count; /* The number of key-value pairs in this table. * 0 <= count <= length. In practice we * never let count == length (see code). */ @@ -160,12 +162,12 @@ struct UHashtable { * and values. Must be prime. */ /* Rehashing thresholds */ - + int32_t highWaterMark; /* If count > highWaterMark, rehash */ int32_t lowWaterMark; /* If count < lowWaterMark, rehash */ float highWaterRatio; /* 0..1; high water as a fraction of length */ float lowWaterRatio; /* 0..1; low water as a fraction of length */ - + int8_t primeIndex; /* Index into our prime table for length. * length == PRIMES[primeIndex] */ UBool allocated; /* Was this UHashtable allocated? */ @@ -188,7 +190,7 @@ U_CDECL_END * @return A pointer to a UHashtable, or 0 if an error occurred. * @see uhash_openSize */ -U_CAPI UHashtable* U_EXPORT2 +U_CAPI UHashtable* U_EXPORT2 uhash_open(UHashFunction *keyHash, UKeyComparator *keyComp, UValueComparator *valueComp, @@ -205,7 +207,7 @@ uhash_open(UHashFunction *keyHash, * @return A pointer to a UHashtable, or 0 if an error occurred. * @see uhash_open */ -U_CAPI UHashtable* U_EXPORT2 +U_CAPI UHashtable* U_EXPORT2 uhash_openSize(UHashFunction *keyHash, UKeyComparator *keyComp, UValueComparator *valueComp, @@ -222,7 +224,7 @@ uhash_openSize(UHashFunction *keyHash, * @return A pointer to a UHashtable, or 0 if an error occurred. * @see uhash_openSize */ -U_CAPI UHashtable* U_EXPORT2 +U_CAPI UHashtable* U_EXPORT2 uhash_init(UHashtable *hash, UHashFunction *keyHash, UKeyComparator *keyComp, @@ -240,7 +242,7 @@ uhash_init(UHashtable *hash, * @return A pointer to a UHashtable, or 0 if an error occurred. * @see uhash_openSize */ -U_CAPI UHashtable* U_EXPORT2 +U_CAPI UHashtable* U_EXPORT2 uhash_initSize(UHashtable *hash, UHashFunction *keyHash, UKeyComparator *keyComp, @@ -252,7 +254,7 @@ uhash_initSize(UHashtable *hash, * Close a UHashtable, releasing the memory used. * @param hash The UHashtable to close. If hash is NULL no operation is performed. */ -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 uhash_close(UHashtable *hash); @@ -263,7 +265,7 @@ uhash_close(UHashtable *hash); * @param fn the function to be used hash keys; must not be NULL * @return the previous key hasher; non-NULL */ -U_CAPI UHashFunction *U_EXPORT2 +U_CAPI UHashFunction *U_EXPORT2 uhash_setKeyHasher(UHashtable *hash, UHashFunction *fn); /** @@ -273,7 +275,7 @@ uhash_setKeyHasher(UHashtable *hash, UHashFunction *fn); * @param fn the function to be used compare keys; must not be NULL * @return the previous key comparator; non-NULL */ -U_CAPI UKeyComparator *U_EXPORT2 +U_CAPI UKeyComparator *U_EXPORT2 uhash_setKeyComparator(UHashtable *hash, UKeyComparator *fn); /** @@ -283,7 +285,7 @@ uhash_setKeyComparator(UHashtable *hash, UKeyComparator *fn); * @param fn the function to be used compare keys; must not be NULL * @return the previous key comparator; non-NULL */ -U_CAPI UValueComparator *U_EXPORT2 +U_CAPI UValueComparator *U_EXPORT2 uhash_setValueComparator(UHashtable *hash, UValueComparator *fn); /** @@ -296,7 +298,7 @@ uhash_setValueComparator(UHashtable *hash, UValueComparator *fn); * @param fn the function to be used delete keys, or NULL * @return the previous key deleter; may be NULL */ -U_CAPI UObjectDeleter *U_EXPORT2 +U_CAPI UObjectDeleter *U_EXPORT2 uhash_setKeyDeleter(UHashtable *hash, UObjectDeleter *fn); /** @@ -309,7 +311,7 @@ uhash_setKeyDeleter(UHashtable *hash, UObjectDeleter *fn); * @param fn the function to be used delete values, or NULL * @return the previous value deleter; may be NULL */ -U_CAPI UObjectDeleter *U_EXPORT2 +U_CAPI UObjectDeleter *U_EXPORT2 uhash_setValueDeleter(UHashtable *hash, UObjectDeleter *fn); /** @@ -319,7 +321,7 @@ uhash_setValueDeleter(UHashtable *hash, UObjectDeleter *fn); * @param hash The UHashtable to set * @param policy The way the hashtable resizes itself, {U_GROW, U_GROW_AND_SHRINK, U_FIXED} */ -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 uhash_setResizePolicy(UHashtable *hash, enum UHashResizePolicy policy); /** @@ -327,7 +329,7 @@ uhash_setResizePolicy(UHashtable *hash, enum UHashResizePolicy policy); * @param hash The UHashtable to query. * @return The number of key-value pairs stored in hash. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_count(const UHashtable *hash); /** @@ -343,7 +345,7 @@ uhash_count(const UHashtable *hash); * @return The previous value, or NULL if none. * @see uhash_get */ -U_CAPI void* U_EXPORT2 +U_CAPI void* U_EXPORT2 uhash_put(UHashtable *hash, void *key, void *value, @@ -361,7 +363,7 @@ uhash_put(UHashtable *hash, * @return The previous value, or NULL if none. * @see uhash_get */ -U_CAPI void* U_EXPORT2 +U_CAPI void* U_EXPORT2 uhash_iput(UHashtable *hash, int32_t key, void* value, @@ -379,7 +381,7 @@ uhash_iput(UHashtable *hash, * @return The previous value, or 0 if none. * @see uhash_get */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_puti(UHashtable *hash, void* key, int32_t value, @@ -397,7 +399,7 @@ uhash_puti(UHashtable *hash, * @return The previous value, or 0 if none. * @see uhash_get */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_iputi(UHashtable *hash, int32_t key, int32_t value, @@ -410,8 +412,8 @@ uhash_iputi(UHashtable *hash, * @param key A pointer key stored in a hashtable * @return The requested item, or NULL if not found. */ -U_CAPI void* U_EXPORT2 -uhash_get(const UHashtable *hash, +U_CAPI void* U_EXPORT2 +uhash_get(const UHashtable *hash, const void *key); /** @@ -421,7 +423,7 @@ uhash_get(const UHashtable *hash, * @param key An integer key stored in a hashtable * @return The requested item, or NULL if not found. */ -U_CAPI void* U_EXPORT2 +U_CAPI void* U_EXPORT2 uhash_iget(const UHashtable *hash, int32_t key); @@ -432,7 +434,7 @@ uhash_iget(const UHashtable *hash, * @param key A pointer key stored in a hashtable * @return The requested item, or 0 if not found. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_geti(const UHashtable *hash, const void* key); /** @@ -442,7 +444,7 @@ uhash_geti(const UHashtable *hash, * @param key An integer key stored in a hashtable * @return The requested item, or 0 if not found. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_igeti(const UHashtable *hash, int32_t key); @@ -452,7 +454,7 @@ uhash_igeti(const UHashtable *hash, * @param key A key stored in a hashtable * @return The item removed, or NULL if not found. */ -U_CAPI void* U_EXPORT2 +U_CAPI void* U_EXPORT2 uhash_remove(UHashtable *hash, const void *key); @@ -462,7 +464,7 @@ uhash_remove(UHashtable *hash, * @param key An integer key stored in a hashtable * @return The item removed, or NULL if not found. */ -U_CAPI void* U_EXPORT2 +U_CAPI void* U_EXPORT2 uhash_iremove(UHashtable *hash, int32_t key); @@ -472,7 +474,7 @@ uhash_iremove(UHashtable *hash, * @param key An key stored in a hashtable * @return The item removed, or 0 if not found. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_removei(UHashtable *hash, const void* key); @@ -482,7 +484,7 @@ uhash_removei(UHashtable *hash, * @param key An integer key stored in a hashtable * @return The item removed, or 0 if not found. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_iremovei(UHashtable *hash, int32_t key); @@ -490,7 +492,7 @@ uhash_iremovei(UHashtable *hash, * Remove all items from a UHashtable. * @param hash The target UHashtable. */ -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 uhash_removeAll(UHashtable *hash); /** @@ -504,7 +506,7 @@ uhash_removeAll(UHashtable *hash); * @param key A key stored in a hashtable * @return a hash element, or NULL if the key is not found. */ -U_CAPI const UHashElement* U_EXPORT2 +U_CAPI const UHashElement* U_EXPORT2 uhash_find(const UHashtable *hash, const void* key); /** @@ -527,7 +529,7 @@ uhash_find(const UHashtable *hash, const void* key); * @return a hash element, or NULL if no further key-value pairs * exist in the table. */ -U_CAPI const UHashElement* U_EXPORT2 +U_CAPI const UHashElement* U_EXPORT2 uhash_nextElement(const UHashtable *hash, int32_t *pos); @@ -542,7 +544,7 @@ uhash_nextElement(const UHashtable *hash, * modified. * @return the value that was removed. */ -U_CAPI void* U_EXPORT2 +U_CAPI void* U_EXPORT2 uhash_removeElement(UHashtable *hash, const UHashElement* e); /******************************************************************** @@ -554,7 +556,7 @@ uhash_removeElement(UHashtable *hash, const UHashElement* e); * @param i The given integer * @return a UHashTok for an integer. */ -/*U_CAPI UHashTok U_EXPORT2 +/*U_CAPI UHashTok U_EXPORT2 uhash_toki(int32_t i);*/ /** @@ -562,7 +564,7 @@ uhash_toki(int32_t i);*/ * @param p The given pointer * @return a UHashTok for a pointer. */ -/*U_CAPI UHashTok U_EXPORT2 +/*U_CAPI UHashTok U_EXPORT2 uhash_tokp(void* p);*/ /******************************************************************** @@ -576,7 +578,7 @@ uhash_tokp(void* p);*/ * @param key The string (const UChar*) to hash. * @return A hash code for the key. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_hashUChars(const UHashTok key); /** @@ -586,7 +588,7 @@ uhash_hashUChars(const UHashTok key); * @param key The string (const char*) to hash. * @return A hash code for the key. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_hashChars(const UHashTok key); /** @@ -606,7 +608,7 @@ uhash_hashIChars(const UHashTok key); * @param key2 The string for comparison * @return true if key1 and key2 are equal, return false otherwise. */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_compareUChars(const UHashTok key1, const UHashTok key2); /** @@ -616,7 +618,7 @@ uhash_compareUChars(const UHashTok key1, const UHashTok key2); * @param key2 The string for comparison * @return true if key1 and key2 are equal, return false otherwise. */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_compareChars(const UHashTok key1, const UHashTok key2); /** @@ -626,7 +628,7 @@ uhash_compareChars(const UHashTok key1, const UHashTok key2); * @param key2 The string for comparison * @return true if key1 and key2 are equal, return false otherwise. */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_compareIChars(const UHashTok key1, const UHashTok key2); /******************************************************************** @@ -638,7 +640,7 @@ uhash_compareIChars(const UHashTok key1, const UHashTok key2); * @param key The string (const char*) to hash. * @return A hash code for the key. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_hashUnicodeString(const UElement key); /** @@ -647,7 +649,7 @@ uhash_hashUnicodeString(const UElement key); * @param key The string (const char*) to hash. * @return A hash code for the key. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_hashCaselessUnicodeString(const UElement key); /******************************************************************** @@ -659,7 +661,7 @@ uhash_hashCaselessUnicodeString(const UElement key); * @param key The string (const char*) to hash. * @return A hash code for the key. */ -U_CAPI int32_t U_EXPORT2 +U_CAPI int32_t U_EXPORT2 uhash_hashLong(const UHashTok key); /** @@ -668,7 +670,7 @@ uhash_hashLong(const UHashTok key); * @param Key2 The integer for comparison * @return true if key1 and key2 are equal, return false otherwise */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_compareLong(const UHashTok key1, const UHashTok key2); /******************************************************************** @@ -679,7 +681,7 @@ uhash_compareLong(const UHashTok key1, const UHashTok key2); * Deleter for Hashtable objects. * @param obj The object to be deleted */ -U_CAPI void U_EXPORT2 +U_CAPI void U_EXPORT2 uhash_deleteHashtable(void *obj); /* Use uprv_free() itself as a deleter for any key or value allocated using uprv_malloc. */ @@ -690,7 +692,7 @@ uhash_deleteHashtable(void *obj); * @param hash2 * @return true if the hashtables are equal and false if not. */ -U_CAPI UBool U_EXPORT2 +U_CAPI UBool U_EXPORT2 uhash_equals(const UHashtable* hash1, const UHashtable* hash2); @@ -699,8 +701,8 @@ uhash_equals(const UHashtable* hash1, const UHashtable* hash2); U_NAMESPACE_BEGIN /** - * \class LocalUResourceBundlePointer - * "Smart pointer" class, closes a UResourceBundle via ures_close(). + * \class LocalUHashtablePointer + * "Smart pointer" class, closes a UHashtable via uhash_close(). * For most methods see the LocalPointerBase base class. * * @see LocalPointerBase @@ -711,6 +713,6 @@ U_DEFINE_LOCAL_OPEN_POINTER(LocalUHashtablePointer, UHashtable, uhash_close); U_NAMESPACE_END -#endif +#endif // U_SHOW_CPLUSPLUS_API #endif