TutHashCreateStr create a hash table with case-sensitive string keys
init_size
the initial size of the hash table
Returns a new hash table suitable for case-sensitive string keys.
None
TutHashCreateStr creates a new hash table with case-sensitive strings for keys.
Providing an init_size
that is too small causes the hash table to be resized often as new entries are inserted.
TutHashCreate, TutHashCreateInt, TutHashCreatePtr, TutHashCreateStri
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 |