TutHashCreateStr


Name

TutHashCreateStr — create a hash table with case-sensitive string keys

Synopsis

T_HASH_TABLE TutHashCreateStr(init_size) 
T_INT4 init_size; 

Arguments

init_size — the initial size of the hash table

Return Values

Returns a new hash table suitable for case-sensitive string keys.

Diagnostics

None

Description

TutHashCreateStr creates a new hash table with case-sensitive strings for keys.

Caution

Providing an init_size that is too small causes the hash table to be resized often as new entries are inserted.

See Also

TutHashCreate, TutHashCreateInt, TutHashCreatePtr, TutHashCreateStri

Examples

This example uses a hash table to look up file pointers from file names:

T_HASH_TABLE hash_table; 
FILE *file; 
 
hash_table = TutHashCreateStr(4); 
file = TutFOpen("foo.tmp", "w"); 
if (file != NULL) { 
  TutHashInsert(hash_table, "foo.tmp", file); 
}  
file = TutFOpen("bar.tmp", "w"); 
if (file != NULL) { 
  TutHashInsert(hash_table, "bar.tmp", file); 
}  
/* this will print foo.tmp’s file pointer in hex. */ 
TutOut("The value for foo.tmp is %x.\n", 
        TutHashLookup(hash_table, "foo.tmp")); 
/* this will print bar.tmp’s file pointer in hex. */ 
TutOut("The value for bar.tmp is %x.\n", 
        TutHashLookup(hash_table, "bar.tmp")); 
/* this will print 0 because baz.tmp isn’t in the table */ 
TutOut("The value for baz.tmp is %x.\n", 
        TutHashLookup(hash_table, "baz.tmp")); 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com