2000-03-28 22:04:39 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2010-06-01 06:10:26 +00:00
|
|
|
* Copyright (C) 1997-2010, International Business Machines
|
2000-03-28 22:04:39 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2000-03-28 22:04:39 +00:00
|
|
|
* Date Name Description
|
|
|
|
* 03/22/00 aliu Creation.
|
2001-07-06 19:53:12 +00:00
|
|
|
* 07/06/01 aliu Modified to support int32_t keys on
|
|
|
|
* platforms with sizeof(void*) < 32.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2000-03-28 22:04:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "uhash.h"
|
2001-08-01 17:37:37 +00:00
|
|
|
#include "hash.h"
|
|
|
|
#include "uvector.h"
|
2000-03-28 22:04:39 +00:00
|
|
|
#include "unicode/unistr.h"
|
2001-11-30 00:06:13 +00:00
|
|
|
#include "unicode/uchar.h"
|
2000-03-28 22:04:39 +00:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* PUBLIC UnicodeString support functions for UHashtable
|
|
|
|
********************************************************************/
|
|
|
|
|
2001-11-21 01:02:11 +00:00
|
|
|
U_CAPI int32_t U_EXPORT2
|
2001-10-16 18:31:13 +00:00
|
|
|
uhash_hashUnicodeString(const UHashTok key) {
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_USE
|
2001-07-06 19:53:12 +00:00
|
|
|
const UnicodeString *str = (const UnicodeString*) key.pointer;
|
|
|
|
return (str == NULL) ? 0 : str->hashCode();
|
2000-03-28 22:04:39 +00:00
|
|
|
}
|
|
|
|
|
2001-11-21 01:02:11 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
2000-03-28 22:04:39 +00:00
|
|
|
uhash_deleteUnicodeString(void *obj) {
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_USE
|
2000-03-28 22:04:39 +00:00
|
|
|
delete (UnicodeString*) obj;
|
|
|
|
}
|
|
|
|
|
2001-11-21 01:02:11 +00:00
|
|
|
U_CAPI UBool U_EXPORT2
|
2001-10-16 18:31:13 +00:00
|
|
|
uhash_compareUnicodeString(const UHashTok key1, const UHashTok key2) {
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_USE
|
2001-07-06 19:53:12 +00:00
|
|
|
const UnicodeString *str1 = (const UnicodeString*) key1.pointer;
|
|
|
|
const UnicodeString *str2 = (const UnicodeString*) key2.pointer;
|
|
|
|
if (str1 == str2) {
|
2000-03-28 22:04:39 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-07-06 19:53:12 +00:00
|
|
|
if (str1 == NULL || str2 == NULL) {
|
2000-03-28 22:04:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-07-06 19:53:12 +00:00
|
|
|
return *str1 == *str2;
|
2000-03-28 22:04:39 +00:00
|
|
|
}
|
2001-06-20 22:37:40 +00:00
|
|
|
|
2001-08-01 17:37:37 +00:00
|
|
|
/**
|
|
|
|
* Deleter for Hashtable objects.
|
|
|
|
*/
|
2001-11-21 01:02:11 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
2001-08-01 17:37:37 +00:00
|
|
|
uhash_deleteHashtable(void *obj) {
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_USE
|
2001-08-01 17:37:37 +00:00
|
|
|
delete (Hashtable*) obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-06-01 06:10:26 +00:00
|
|
|
* Deleter for UObject instances.
|
2001-08-01 17:37:37 +00:00
|
|
|
*/
|
2001-11-21 01:02:11 +00:00
|
|
|
U_CAPI void U_EXPORT2
|
2010-06-01 06:10:26 +00:00
|
|
|
uhash_deleteUObject(void *obj) {
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_USE
|
2010-06-01 06:10:26 +00:00
|
|
|
delete (UObject*) obj;
|
2001-08-01 17:37:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//eof
|