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