Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

TNL::StringTable Namespace Reference

A global table for the hashing and tracking of network strings. More...


Compounds

struct  Node
 This is internal to the _StringTable class. More...


Implementation details

enum  { InitialHashTableSize = 1237, InitialNodeListSize = 2048, CompactThreshold = 32768 }
void resizeHashTable (const U32 newSize)
 Resize the StringTable to be able to hold newSize items.

void compact ()
 compacts the string data associated with the string table.

U32 hashString (const char *str)
 Hash a string into a U32.

U32 hashStringn (const char *str, S32 len)
 Hash a string of given length into a U32.

StringTableEntryId insert (const char *val, const bool caseSens)
 Adds a string to the string table, and returns the id of the string.

StringTableEntryId insertn (const char *val, S32 len, const bool caseSens)
 Adds a string to the string table, and returns the id of the string.

StringTableEntryId lookup (const char *val, const bool caseSens)
 Determines if a string is in the string table, and returns the id of the string, or 0 if the string is not in the table.

StringTableEntryId lookupn (const char *val, S32 len, const bool caseSens)
 Determines if a string is in the string table, and returns the id of the string, or 0 if the string is not in the table.

Node ** mNodeList = NULL
 Master list of string table entry nodes.

StringTableEntryId * mBuckets = NULL
 Hash table buckets, organized by string index.

U32 mNumBuckets = 0
 number of hash buckets in the table

U32 mNodeListSize = 0
 number of elements in the node list

StringTableEntryId mNodeListFreeEntry = 0
 index of first free entry in the node list

U32 mItemCount = 0
 number of strings in the table

DataChunkermMemPool = NULL
 memory pool from which string table data is allocated

U32 mFreeStringDataSize = 0
 number of bytes freed by deallocated strings. When this number exceeds CompactThreshold, the table is compacted.


Detailed Description

A global table for the hashing and tracking of network strings.

Enumeration Type Documentation

anonymous enum
 

Enumeration values:
InitialHashTableSize  Initial size of string hash table.
InitialNodeListSize  Initial size of node id remap table.
CompactThreshold  Number of string bytes freed before compaction occurs.

Definition at line 53 of file netStringTable.cpp.


Function Documentation

StringTableEntryId TNL::StringTable::insert const char *    string,
bool    caseSens = true
 

Adds a string to the string table, and returns the id of the string.

Parameters:
string  String to check in the table (and add).
caseSens  Determines whether case matters.

Definition at line 182 of file netStringTable.cpp.

References insertn().

StringTableEntryId TNL::StringTable::insertn const char *    string,
S32    len,
bool    caseSens = true
 

Adds a string to the string table, and returns the id of the string.

Parameters:
string  String to check in the table (and add).
len  Length of the string in bytes.
caseSens  Determines whether case matters.

Definition at line 227 of file netStringTable.cpp.

References TNL::DataChunker::alloc(), TNL::StringTable::Node::hash, hashStringn(), InitialNodeListSize, TNL::StringTable::Node::masterIndex, mBuckets, mItemCount, mNodeListFreeEntry, mNodeListSize, mNumBuckets, TNL::StringTable::Node::nextIndex, TNL::StringTable::Node::refCount, resizeHashTable(), TNL::StringTable::Node::stringData, TNL::StringTable::Node::stringLen, and TNL::U32.

Referenced by insert().

StringTableEntryId TNL::StringTable::lookup const char *    string,
bool    caseSens = true
 

Determines if a string is in the string table, and returns the id of the string, or 0 if the string is not in the table.

Parameters:
string  String to check in the table (but not add).
caseSens  Determines whether case matters.

Definition at line 292 of file netStringTable.cpp.

References hashString(), mBuckets, mNumBuckets, TNL::StringTable::Node::nextIndex, TNL::StringTable::Node::stringData, and TNL::U32.

StringTableEntryId TNL::StringTable::lookupn const char *    string,
S32    len,
bool    caseSens = true
 

Determines if a string is in the string table, and returns the id of the string, or 0 if the string is not in the table.

Parameters:
string  String to check in the table (but not add).
len  Length of string in bytes.
caseSens  Determines whether case matters.

Definition at line 310 of file netStringTable.cpp.

References hashStringn(), mBuckets, mNumBuckets, TNL::StringTable::Node::nextIndex, TNL::StringTable::Node::stringData, and TNL::U32.

void TNL::StringTable::resizeHashTable const U32    newSize
 

Resize the StringTable to be able to hold newSize items.

This is called automatically by the StringTable when the table is full past a certain threshhold.

Parameters:
newSize  Number of new items to allocate space for.

Definition at line 328 of file netStringTable.cpp.

References TNL::StringTable::Node::hash, TNL::StringTable::Node::masterIndex, mBuckets, mNumBuckets, TNL::StringTable::Node::nextIndex, and TNL::U32.

Referenced by insertn().


Generated on Thu Aug 18 16:03:39 2005 for Robin Hood: Thieves & Knights by doxygen1.2.18