Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

uhash.h File Reference

Go to the source code of this file.

Compounds

struct  UHashElement
struct  UHashtable

Typedefs

typedef struct UHashElement UHashElement

Enumerations

enum  UHashResizePolicy { U_GROW, U_GROW_AND_SHRINK, U_FIXED }
 This specifies whether or not, and how, the hastable resizes itself. More...


Functions

U_CDECL_END U_CAPI UHashtableuhash_open (UHashFunction keyHash, UKeyComparator keyComp, UErrorCode *status)
 Initialize a new UHashtable. More...

U_CAPI UHashtableuhash_openSize (UHashFunction keyHash, UKeyComparator keyComp, int32_t size, UErrorCode *status)
 Initialize a new UHashtable with a given initial size. More...

U_CAPI void uhash_close (UHashtable *hash)
 Close a UHashtable, releasing the memory used. More...

U_CAPI UHashFunction uhash_setKeyHasher (UHashtable *hash, UHashFunction fn)
 Set the function used to hash keys. More...

U_CAPI UKeyComparator uhash_setKeyComparator (UHashtable *hash, UKeyComparator fn)
 Set the function used to compare keys. More...

U_CAPI UObjectDeleter uhash_setKeyDeleter (UHashtable *hash, UObjectDeleter fn)
 Set the function used to delete keys. More...

U_CAPI UObjectDeleter uhash_setValueDeleter (UHashtable *hash, UObjectDeleter fn)
 Set the function used to delete values. More...

U_CAPI void uhash_setResizePolicy (UHashtable *hash, enum UHashResizePolicy policy)
 Specify whether or not, and how, the hastable resizes itself. More...

U_CAPI int32_t uhash_count (const UHashtable *hash)
 Get the number of key-value pairs stored in a UHashtable. More...

U_CAPI void* uhash_put (UHashtable *hash, void *key, void *value, UErrorCode *status)
 Put an item in a UHashtable. More...

U_CAPI void* uhash_get (const UHashtable *hash, const void *key)
 Get an item from a UHashtable. More...

U_CAPI void* uhash_remove (UHashtable *hash, const void *key)
 Remove an item from a UHashtable. More...

U_CAPI void uhash_removeAll (UHashtable *hash)
 Remove all items from a UHashtable. More...

U_CAPI const UHashElementuhash_nextElement (const UHashtable *hash, int32_t *pos)
 Iterate through the elements of a UHashtable. More...

U_CAPI void* uhash_removeElement (UHashtable *hash, const UHashElement* e)
 Remove an element, returned by uhash_nextElement(), from the table. More...

U_CAPI int32_t uhash_hashUChars (const void *key)
 Generate a hash code for a null-terminated UChar* string. More...

U_CAPI int32_t uhash_hashChars (const void *key)
 Generate a hash code for a null-terminated char* string. More...

U_CAPI int32_t uhash_hashUCharsN (const UChar *key, int32_t length)
U_CAPI int32_t uhash_hashIChars (const void *key)
 Generate a case-insensitive hash code for a null-terminated char* string. More...

U_CAPI UBool uhash_compareUChars (const void *key1, const void *key2)
 Comparator for null-terminated UChar* strings. More...

U_CAPI UBool uhash_compareChars (const void *key1, const void *key2)
 Comparator for null-terminated char* strings. More...

U_CAPI UBool uhash_compareIChars (const void *key1, const void *key2)
 Case-insensitive comparator for null-terminated char* strings. More...

U_CAPI int32_t uhash_hashUnicodeString (const void *key)
 Hash function for UnicodeString* keys.

U_CAPI UBool uhash_compareUnicodeString (const void *key1, const void *key2)
 Comparator function for UnicodeString* keys.

U_CAPI void uhash_deleteUnicodeString (void *obj)
 Deleter function for UnicodeString* keys or values.

U_CAPI int32_t uhash_hashLong (const void *key)
 Hash function for 32-bit integer keys.

U_CAPI UBool uhash_compareLong (const void *key1, const void *key2)
 Comparator function for 32-bit integer keys.

U_CAPI void uhash_freeBlock (void *obj)
 Deleter for any key or value allocated using uprv_malloc. More...


Variables

U_CDECL_BEGIN typedef int32_t (*  U_CALLCONV )(const void* key)
 A hashing function. More...


Typedef Documentation

typedef struct UHashElement UHashElement
 

Definition at line 111 of file uhash.h.


Enumeration Type Documentation

enum UHashResizePolicy
 

This specifies whether or not, and how, the hastable resizes itself.

See uhash_setResizePolicy().

Enumeration values:
U_GROW  
U_GROW_AND_SHRINK  
U_FIXED  

Definition at line 117 of file uhash.h.


Function Documentation

U_CAPI void uhash_close ( UHashtable * hash )
 

Close a UHashtable, releasing the memory used.

Parameters:
hash   The UHashtable to close.

Referenced by Hashtable::~Hashtable().

U_CAPI UBool uhash_compareChars ( const void * key1,
const void * key2 )
 

Comparator for null-terminated char* strings.

Use together with uhash_hashChars.

U_CAPI UBool uhash_compareIChars ( const void * key1,
const void * key2 )
 

Case-insensitive comparator for null-terminated char* strings.

Use together with uhash_hashIChars.

U_CAPI UBool uhash_compareLong ( const void * key1,
const void * key2 )
 

Comparator function for 32-bit integer keys.

U_CAPI UBool uhash_compareUChars ( const void * key1,
const void * key2 )
 

Comparator for null-terminated UChar* strings.

Use together with uhash_hashUChars.

U_CAPI UBool uhash_compareUnicodeString ( const void * key1,
const void * key2 )
 

Comparator function for UnicodeString* keys.

U_CAPI int32_t uhash_count ( const UHashtable * hash )
 

Get the number of key-value pairs stored in a UHashtable.

Parameters:
hash   The UHashtable to query.
Returns:
The number of key-value pairs stored in hash.

Referenced by Hashtable::count().

U_CAPI void uhash_deleteUnicodeString ( void * obj )
 

Deleter function for UnicodeString* keys or values.

U_CAPI void uhash_freeBlock ( void * obj )
 

Deleter for any key or value allocated using uprv_malloc.

Calls uprv_free.

U_CAPI void * uhash_get ( const UHashtable * hash,
const void * key )
 

Get an item from a UHashtable.

Parameters:
hash   The target UHashtable.
key   The hash code of the desired value.
Returns:
The requested item, or 0 if not found.

Referenced by Hashtable::get().

U_CAPI int32_t uhash_hashChars ( const void * key )
 

Generate a hash code for a null-terminated char* string.

If the string is not null-terminated do not use this function. Use together with uhash_compareChars.

Parameters:
key   The string (const char*) to hash.
Returns:
A hash code for the key.

U_CAPI int32_t uhash_hashIChars ( const void * key )
 

Generate a case-insensitive hash code for a null-terminated char* string.

If the string is not null-terminated do not use this function. Use together with uhash_compareIChars.

Parameters:
key   The string (const char*) to hash.
Returns:
A hash code for the key.

U_CAPI int32_t uhash_hashLong ( const void * key )
 

Hash function for 32-bit integer keys.

U_CAPI int32_t uhash_hashUChars ( const void * key )
 

Generate a hash code for a null-terminated UChar* string.

If the string is not null-terminated do not use this function. Use together with uhash_compareUChars.

Parameters:
key   The string (const UChar*) to hash.
Returns:
A hash code for the key.

U_CAPI int32_t uhash_hashUCharsN ( const UChar * key,
int32_t length )
 

U_CAPI int32_t uhash_hashUnicodeString ( const void * key )
 

Hash function for UnicodeString* keys.

U_CAPI const UHashElement * uhash_nextElement ( const UHashtable * hash,
int32_t * pos )
 

Iterate through the elements of a UHashtable.

The caller must not modify the returned object. However, uhash_removeElement() may be called during iteration to remove an element from the table. Iteration may safely be resumed afterwards. If uhash_put() is called during iteration the iteration will then be out of sync and should be restarted.

Parameters:
hash   The target UHashtable.
pos   This should be set to -1 initially, and left untouched thereafter.
Returns:
a hash element, or NULL if no further key-value pairs exist in the table.

Referenced by Hashtable::nextElement().

U_CDECL_END U_CAPI UHashtable * uhash_open ( UHashFunction keyHash,
UKeyComparator keyComp,
UErrorCode * status )
 

Initialize a new UHashtable.

Parameters:
keyHash   A pointer to the key hashing function. Must not be NULL.
keyComp   A pointer to the function that compares keys. Must not be NULL.
status   A pointer to an UErrorCode to receive any errors.
Returns:
A pointer to a UHashtable, or 0 if an error occurred.
See also:
uhash_openSize

Referenced by Hashtable::Hashtable().

U_CAPI UHashtable * uhash_openSize ( UHashFunction keyHash,
UKeyComparator keyComp,
int32_t size,
UErrorCode * status )
 

Initialize a new UHashtable with a given initial size.

Parameters:
keyHash   A pointer to the key hashing function. Must not be NULL.
keyComp   A pointer to the function that compares keys. Must not be NULL.
size   The initial capacity of this hash table.
status   A pointer to an UErrorCode to receive any errors.
Returns:
A pointer to a UHashtable, or 0 if an error occurred.
See also:
uhash_open

U_CAPI void * uhash_put ( UHashtable * hash,
void * key,
void * value,
UErrorCode * status )
 

Put an item in a UHashtable.

If the keyDeleter is non-NULL, then the hashtable owns 'key' after this call. If the valueDeleter is non-NULL, then the hashtable owns 'value' after this call. Storing a NULL value is the same as calling uhash_remove().

Parameters:
hash   The target UHashtable.
key   The key to store.
value   The value to store, may be NULL (see above).
status   A pointer to an UErrorCode to receive any errors.
Returns:
The previous value, or NULL if none.
See also:
uhash_get

Referenced by Hashtable::put().

U_CAPI void * uhash_remove ( UHashtable * hash,
const void * key )
 

Remove an item from a UHashtable.

Parameters:
hash   The target UHashtable.
key   The hash code of the value to be removed.
Returns:
The item removed, or 0 if not found.

Referenced by Hashtable::remove().

U_CAPI void uhash_removeAll ( UHashtable * hash )
 

Remove all items from a UHashtable.

Parameters:
hash   The target UHashtable.

U_CAPI void * uhash_removeElement ( UHashtable * hash,
const UHashElement * e )
 

Remove an element, returned by uhash_nextElement(), from the table.

Iteration may be safely continued afterwards.

Parameters:
hash   The hashtable
e   The element, returned by uhash_nextElement(), to remove. Must not be NULL. Must not be an empty or deleted element (as long as this was returned by uhash_nextElement() it will not be empty or deleted). Note: Although this parameter is const, it will be modified.
Returns:
the value that was removed.

U_CAPI UKeyComparator uhash_setKeyComparator ( UHashtable * hash,
UKeyComparator fn )
 

Set the function used to compare keys.

The default comparison is a void* pointer comparison.

Parameters:
fn   the function to be used compare keys; must not be NULL
Returns:
the previous key comparator; non-NULL

U_CAPI UObjectDeleter uhash_setKeyDeleter ( UHashtable * hash,
UObjectDeleter fn )
 

Set the function used to delete keys.

If this function pointer is NULL, this hashtable does not delete keys. If it is non-NULL, this hashtable does delete keys. This function should be set once before any elements are added to the hashtable and should not be changed thereafter.

Parameters:
fn   the function to be used delete keys, or NULL
Returns:
the previous key deleter; may be NULL

Referenced by Hashtable::Hashtable().

U_CAPI UHashFunction uhash_setKeyHasher ( UHashtable * hash,
UHashFunction fn )
 

Set the function used to hash keys.

Parameters:
fn   the function to be used hash keys; must not be NULL
Returns:
the previous key hasher; non-NULL

U_CAPI void uhash_setResizePolicy ( UHashtable * hash,
enum UHashResizePolicy policy )
 

Specify whether or not, and how, the hastable resizes itself.

By default, tables grow but do not shrink (policy U_GROW). See enum UHashResizePolicy.

U_CAPI UObjectDeleter uhash_setValueDeleter ( UHashtable * hash,
UObjectDeleter fn )
 

Set the function used to delete values.

If this function pointer is NULL, this hashtable does not delete values. If it is non-NULL, this hashtable does delete values. This function should be set once before any elements are added to the hashtable and should not be changed thereafter.

Parameters:
fn   the function to be used delete values, or NULL
Returns:
the previous value deleter; may be NULL

Referenced by Hashtable::setValueDeleter().


Variable Documentation

U_CDECL_BEGIN typedef int32_t(* U_CALLCONV)(const void *key)
 

A hashing function.

Parameters:
key   A key stored in a hashtable
Returns:
A NON-NEGATIVE hash code for parm.

Definition at line 81 of file uhash.h.


Generated at Tue Dec 5 17:55:48 2000 for ICU by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000