Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

HashString Class Reference

#include <hashstring.h>

List of all members.


Detailed Description

Hashed version of std::string for faster comparision The HashString stores a hash of the string for fast early-out comparision with other hashed strings by comparing the hash, and only if equal compare the actual string data. Overloads some useful operations of std::string but not all, if you need to access the string data directly, remember to call HashMe() if you modify it (not needed if you simply read from it, naturally).

Author:
Mattias Jansson (mattias@realityrift.com)

Robert A Balfe (rbalfe@attbi.com)


Public Member Functions

 HashString ()
 HashString (const HashString &rstrRef)
 HashString (const std::string &rstrRef)
 HashString (const char *pcRef, int iNum)
 HashString (const char *pszRef)
 HashString (int iNum, const char cData)
bool Compare (const HashString &rstrRef) const
bool Compare (unsigned int uiHash) const
unsigned int GetHash () const
HashStringHashMe ()
size_t length () const
const char * c_str () const
bool operator== (const HashString &rstrRef) const
bool operator== (unsigned int uiHash) const
bool operator== (const std::string &rstrRef) const
bool operator== (const char *pszRef) const
bool operator!= (const HashString &rstrRef) const
bool operator!= (unsigned int uiHash) const
bool operator!= (const std::string &rstrRef) const
bool operator!= (const char *pszRef) const
HashStringoperator= (const HashString &rstrRef)
HashStringoperator= (const std::string &rstrRef)
HashStringoperator= (const char *pszRef)
HashStringoperator+= (const HashString &rstrRef)
HashStringoperator+= (const std::string &rstrRef)
HashStringoperator+= (const char *pszRef)
 operator std::string & ()
 operator const std::string & () const
bool operator< (const HashString &rstrString) const

Public Attributes

std::string m_strData

Protected Attributes

unsigned int m_uiHash


Constructor & Destructor Documentation

HashString  )  [inline]
 

Empty string

HashString const HashString rstrRef  )  [inline]
 

Copy string

Parameters:
rstrRef String to copy

HashString const std::string &  rstrRef  )  [inline]
 

Copy string

Parameters:
rstrRef String to copy

HashString const char *  pcRef,
int  iNum
[inline]
 

Construct from char array

Parameters:
pcRef String
iNum Length

HashString const char *  pszRef  )  [inline]
 

Construct from zero terminated string

Parameters:
pszRef String

HashString int  iNum,
const char  cData
[inline]
 

Fill string with data

Parameters:
iNum Length
cData Character to fill string with


Member Function Documentation

bool Compare const HashString rstrRef  )  const [inline]
 

Compare hashed strings

Parameters:
rstrRef String to compare with
Returns:
true if equal, false if not

bool Compare unsigned int  uiHash  )  const [inline]
 

Compare hash values

Parameters:
uiHash Hash value
Returns:
true if our hash equals, false if not

unsigned int GetHash  )  const [inline]
 

Returns:
Hash value

HashString & HashMe  )  [inline]
 

Calculate hash value of string

Returns:
Hashed string object (this)

size_t length  )  const [inline]
 

Returns:
Length of string

const char * c_str  )  const [inline]
 

Returns:
pointer to C-style string

bool operator== const HashString rstrRef  )  const [inline]
 

Compare hashed strings

Parameters:
rstrRef String to compare with
Returns:
true if equal, false if not

bool operator== unsigned int  uiHash  )  const [inline]
 

Compare hash values

Parameters:
uiHash Hash value
Returns:
true if our hash equals, false if not

bool operator== const std::string &  rstrRef  )  const [inline]
 

Compare with std::string

Parameters:
rstrRef String to compare with
Returns:
true if strings equals, false if not

bool operator== const char *  pszRef  )  const [inline]
 

Compare with char ptr

Parameters:
pszRef String to compare with
Returns:
true if strings equals, false if not

bool operator!= const HashString rstrRef  )  const [inline]
 

Compare hashed strings

Parameters:
rstrRef String to compare with
Returns:
true if equal, false if not

bool operator!= unsigned int  uiHash  )  const [inline]
 

Compare hash values

Parameters:
uiHash Hash value
Returns:
true if our hash equals, false if not

bool operator!= const std::string &  rstrRef  )  const [inline]
 

Compare with std::string

Parameters:
rstrRef String to compare with
Returns:
true if strings equals, false if not

bool operator!= const char *  pszRef  )  const [inline]
 

Compare with char ptr

Parameters:
pszRef String to compare with
Returns:
true if strings equals, false if not

HashString & operator= const HashString rstrRef  )  [inline]
 

Assign from hashed string

Parameters:
rstrRef String
Returns:
this

HashString & operator= const std::string &  rstrRef  )  [inline]
 

Assign from std::string

Parameters:
rstrRef String
Returns:
this

HashString & operator= const char *  pszRef  )  [inline]
 

Assign from null-terminated char array

Parameters:
pszRef String
Returns:
this

HashString & operator+= const HashString rstrRef  )  [inline]
 

Concatenate string

Parameters:
rstrRef String to add to end of this string
Returns:
this

HashString & operator+= const std::string &  rstrRef  )  [inline]
 

Concatenate string

Parameters:
rstrRef String to add to end of this string
Returns:
this

HashString & operator+= const char *  pszRef  )  [inline]
 

Concatenate string

Parameters:
pszRef Null-terminated string to add to end of this string
Returns:
this

operator std::string &  )  [inline]
 

Implicit conversion to std::string

operator const std::string &  )  const [inline]
 

Implicit conversion to std::string

bool operator< const HashString rstrString  )  const [inline]
 

Comparison

Parameters:
rstrString Reference string to compare with
Returns:
true if this string is less than reference


Member Data Documentation

unsigned int m_uiHash [protected]
 

Hash value of string

std::string m_strData
 

String data, if you modify this directly you must remember to call HashMe() to update the hash value


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:11 2004 for NeoEngine by doxygen 1.3.5