2
******************************************************************************
3
* Copyright (C) 1997-2001, 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
******************************************************************************
16
#include "unicode/unistr.h"
17
#include "unicode/uchar.h"
19
/********************************************************************
20
* PUBLIC UnicodeString support functions for UHashtable
21
********************************************************************/
23
U_CAPI int32_t U_EXPORT2
24
uhash_hashUnicodeString(const UHashTok key) {
26
const UnicodeString *str = (const UnicodeString*) key.pointer;
27
return (str == NULL) ? 0 : str->hashCode();
30
U_CAPI int32_t U_EXPORT2
31
uhash_hashCaselessUnicodeString(const UHashTok key) {
33
const UnicodeString *str = (const UnicodeString*) key.pointer;
37
// Inefficient; a better way would be to have a hash function in
38
// UnicodeString that does case folding on the fly.
39
UnicodeString copy(*str);
40
return copy.foldCase().hashCode();
44
uhash_deleteUnicodeString(void *obj) {
46
delete (UnicodeString*) obj;
49
U_CAPI UBool U_EXPORT2
50
uhash_compareUnicodeString(const UHashTok key1, const UHashTok key2) {
52
const UnicodeString *str1 = (const UnicodeString*) key1.pointer;
53
const UnicodeString *str2 = (const UnicodeString*) key2.pointer;
57
if (str1 == NULL || str2 == NULL) {
60
return *str1 == *str2;
63
U_CAPI UBool U_EXPORT2
64
uhash_compareCaselessUnicodeString(const UHashTok key1, const UHashTok key2) {
66
const UnicodeString *str1 = (const UnicodeString*) key1.pointer;
67
const UnicodeString *str2 = (const UnicodeString*) key2.pointer;
71
if (str1 == NULL || str2 == NULL) {
74
return str1->caseCompare(*str2, U_FOLD_CASE_DEFAULT) == 0;
78
* Deleter for Hashtable objects.
81
uhash_deleteHashtable(void *obj) {
83
delete (Hashtable*) obj;
87
* Deleter for UVector objects.
90
uhash_deleteUVector(void *obj) {
92
delete (UVector*) obj;