]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/uhash_us.cpp
ICU-400.37.tar.gz
[apple/icu.git] / icuSources / common / uhash_us.cpp
1 /*
2 ******************************************************************************
3 * Copyright (C) 1997-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************
6 * Date Name Description
7 * 03/22/00 aliu Creation.
8 * 07/06/01 aliu Modified to support int32_t keys on
9 * platforms with sizeof(void*) < 32.
10 ******************************************************************************
11 */
12
13 #include "uhash.h"
14 #include "hash.h"
15 #include "uvector.h"
16 #include "unicode/unistr.h"
17 #include "unicode/uchar.h"
18
19 /********************************************************************
20 * PUBLIC UnicodeString support functions for UHashtable
21 ********************************************************************/
22
23 U_CAPI int32_t U_EXPORT2
24 uhash_hashUnicodeString(const UHashTok key) {
25 U_NAMESPACE_USE
26 const UnicodeString *str = (const UnicodeString*) key.pointer;
27 return (str == NULL) ? 0 : str->hashCode();
28 }
29
30 U_CAPI void U_EXPORT2
31 uhash_deleteUnicodeString(void *obj) {
32 U_NAMESPACE_USE
33 delete (UnicodeString*) obj;
34 }
35
36 U_CAPI UBool U_EXPORT2
37 uhash_compareUnicodeString(const UHashTok key1, const UHashTok key2) {
38 U_NAMESPACE_USE
39 const UnicodeString *str1 = (const UnicodeString*) key1.pointer;
40 const UnicodeString *str2 = (const UnicodeString*) key2.pointer;
41 if (str1 == str2) {
42 return TRUE;
43 }
44 if (str1 == NULL || str2 == NULL) {
45 return FALSE;
46 }
47 return *str1 == *str2;
48 }
49
50 /**
51 * Deleter for Hashtable objects.
52 */
53 U_CAPI void U_EXPORT2
54 uhash_deleteHashtable(void *obj) {
55 U_NAMESPACE_USE
56 delete (Hashtable*) obj;
57 }
58
59 /**
60 * Deleter for UVector objects.
61 */
62 U_CAPI void U_EXPORT2
63 uhash_deleteUVector(void *obj) {
64 U_NAMESPACE_USE
65 delete (UVector*) obj;
66 }
67
68 //eof