neo::core::HashString Class Reference

#include <core/hashstring.h>

List of all members.


Detailed Description

Hashed string for faster comparison. If you find yourself calling methods taking hashed string arguments in time-critical code and passing non-changing values as those string, you could improve performance by making the keys static data or member data, saving the hash calculation for each call.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Member Functions

 HashString ()
 Construct empty string.
 HashString (const std::string &str)
 Assign string.
 HashString (const char *p_str)
 Assign string.
 HashString (const char *p_str, unsigned int num)
 Assign substring.
unsigned int getHash () const
 Get hash value.
std::string::size_type length () const
 Get length of string.
const std::string & str () const
 Get string.
const char * c_str () const
 Get C-style string.
bool operator== (const HashString &rhs) const
 Compare hashed strings.
bool operator== (const std::string &rhs) const
 Compare strings.
bool operator== (const char *p_rhs) const
 Compare strings.
bool operator!= (const HashString &rhs) const
 Compare hashed strings.
bool operator!= (const std::string &rhs) const
 Compare strings.
bool operator!= (const char *p_rhs) const
 Compare strings.
HashStringoperator= (const HashString &rhs)
 Assign.
HashStringoperator= (const std::string &rhs)
 Assign.
HashStringoperator= (const char *p_rhs)
 Assign.
HashStringoperator+= (const HashString &rhs)
 Concatenate and assign.
HashStringoperator+= (const std::string &rhs)
 Concatenate and assign.
HashStringoperator+= (const char *p_rhs)
 Concatenate and assign.
const HashString operator+ (const HashString &rhs) const
 Concatenate.
const HashString operator+ (const std::string &rhs)
 Concatenate.
const HashString operator+ (const char *p_rhs)
 Concatenate.
 operator const std::string & () const
 Implicit conversion to std::string.


Constructor & Destructor Documentation

neo::core::HashString::HashString ( const std::string &  str  )  [inline]

Assign string and calculate hash

Parameters:
str String

neo::core::HashString::HashString ( const char *  p_str  )  [inline]

Assign string and calculate hash

Parameters:
p_str String

neo::core::HashString::HashString ( const char *  p_str,
unsigned int  num 
) [inline]

Assign substring and calculate hash

Parameters:
p_str String
num Length of string


Member Function Documentation

unsigned int neo::core::HashString::getHash (  )  const [inline]

Returns:
Hash value of string

std::string::size_type neo::core::HashString::length (  )  const [inline]

Returns:
Length of string

const std::string & neo::core::HashString::str (  )  const [inline]

Returns:
String

const char * neo::core::HashString::c_str (  )  const [inline]

Get string as C-style char*

Returns:
Pointer to C-style string

bool neo::core::HashString::operator== ( const HashString rhs  )  const [inline]

Compare hashed strings by first comparing hash values, and only comparing the actual strings if those match (must be done to avoid false positives for hash collisions).

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

bool neo::core::HashString::operator== ( const std::string &  rhs  )  const [inline]

Compare strings (does not use hash)

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

bool neo::core::HashString::operator== ( const char *  p_rhs  )  const [inline]

Compare strings as C-style char* (does not use hash)

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

bool neo::core::HashString::operator!= ( const HashString rhs  )  const [inline]

Compare hashed strings by first comparing hash values, and only comparing the actual strings if those match (must be done to avoid false positives for hash collisions).

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

bool neo::core::HashString::operator!= ( const std::string &  rhs  )  const [inline]

Compare strings (does not use hash)

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

bool neo::core::HashString::operator!= ( const char *  p_rhs  )  const [inline]

Compare strings as C-style char* (does not use hash)

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

HashString & neo::core::HashString::operator= ( const HashString rhs  )  [inline]

Assign from hashed string

Parameters:
rhs String
Returns:
Self-reference

HashString & neo::core::HashString::operator= ( const std::string &  rhs  )  [inline]

Assign from string and calculate hash

Parameters:
rhs String
Returns:
Self-reference

HashString & neo::core::HashString::operator= ( const char *  p_rhs  )  [inline]

Assign from C-style string and calculate hash

Parameters:
p_rhs String
Returns:
Self-reference

HashString & neo::core::HashString::operator+= ( const HashString rhs  )  [inline]

Concatenate with hashed string and calculate hash

Parameters:
rhs String
Returns:
Self-reference

HashString & neo::core::HashString::operator+= ( const std::string &  rhs  )  [inline]

Concatenate with string and calculate hash

Parameters:
rhs String
Returns:
Self-reference

HashString & neo::core::HashString::operator+= ( const char *  p_rhs  )  [inline]

Concatenate with C-style string and calculate hash

Parameters:
p_rhs String
Returns:
Self-reference

const HashString neo::core::HashString::operator+ ( const HashString rhs  )  const [inline]

Concatenate with hashed string and calculate hash

Parameters:
rhs String
Returns:
Resulting string

const HashString neo::core::HashString::operator+ ( const std::string &  rhs  )  [inline]

Concatenate with string and calculate hash

Parameters:
rhs String
Returns:
Resulting string

const HashString neo::core::HashString::operator+ ( const char *  p_rhs  )  [inline]

Concatenate with C-style string and hash

Parameters:
p_rhs String
Returns:
Resulting string


The documentation for this class was generated from the following file:
Generated on Sat Feb 17 20:51:02 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1