Spinning Topp Logo BlackTopp Studios
inc
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Mezzanine::HashedString32 Class Reference

An identifier that compares as fast as an integer but has a string. More...

#include <hashedstring.h>

+ Collaboration diagram for Mezzanine::HashedString32:

Public Member Functions

 HashedString32 ()
 NonComputing Constructor. More...
 
 HashedString32 (const String &StartingString)
 String Constructor. More...
 
 HashedString32 (const String &StartingString, Int32 PrecomputedHash)
 Precomputed Constructor. More...
 
 HashedString32 (const HashedString32 &StartingString)
 Copy constructor. More...
 
Int32 GetHash () const
 Get the 32 bit as an Int32. More...
 
String GetString () const
 Get the string that was used to calculate the hash. More...
 
bool operator!= (const HashedString32 &Other) const
 Compare The hash of this and another string for inequality. More...
 
bool operator< (const HashedString32 &Other) const
 Provide a semantically useless, but quite fast sorting order for std containers based on only hashes. More...
 
bool operator== (const HashedString32 &Other) const
 Compare The hash of this and another string for equality. More...
 
bool operator> (const HashedString32 &Other) const
 Provide a semantically useless, but quite fast sorting order for std containers based on only hashes. More...
 
void ProtoDeSerialize (const XML::Node &OneNode)
 Take the data stored in an XML and overwrite this instance of this object with it. More...
 
void ProtoSerialize (XML::Node &CurrentRoot) const
 Convert this class to an XML::Node ready for serialization. More...
 
void SetString (const String &NewString)
 Set a new string and recalculate its hash. More...
 

Static Public Member Functions

static String GetSerializableName ()
 Get the name of the the XML tag this class will leave behind as its instances are serialized. More...
 
static Int32 Murmur32bit (const String &ToBeHashed)
 Compute a MurmurA aka MurmurX86-32bit has of a string and return it. More...
 

Protected Attributes

Int32 Hash
 The computed hash.
 
String TheString
 The Actual string to store.
 

Detailed Description

An identifier that compares as fast as an integer but has a string.

This computes a MurmurA(x86 32bit) hash on creation. This is used in all comparisons, this means that in excedingly rare situations that hash collisions could cause silent failure.

Internally programming la

Definition at line 65 of file hashedstring.h.

Constructor & Destructor Documentation

Mezzanine::HashedString32::HashedString32 ( )

NonComputing Constructor.

Skip the hashing overhead and just do the work for h

Definition at line 57 of file hashedstring.cpp.

Mezzanine::HashedString32::HashedString32 ( const String StartingString)

String Constructor.

Parameters
StartingStringThe String to work with

Compute the hash of the String and hang onto both for future use.

Definition at line 61 of file hashedstring.cpp.

Mezzanine::HashedString32::HashedString32 ( const String StartingString,
Int32  PrecomputedHash 
)

Precomputed Constructor.

Parameters
StartingStringThe String to work with
PrecomputedHashThe value

Does not Compute the hash of the String, Just trusts whatever it is given.

Definition at line 65 of file hashedstring.cpp.

Mezzanine::HashedString32::HashedString32 ( const HashedString32 StartingString)

Copy constructor.

Parameters
StartingStringThe other hashed string

Definition at line 69 of file hashedstring.cpp.

Member Function Documentation

Int32 Mezzanine::HashedString32::GetHash ( ) const

Get the 32 bit as an Int32.

Returns
an Int32 with the hash in it.

Definition at line 104 of file hashedstring.cpp.

String Mezzanine::HashedString32::GetSerializableName ( )
static

Get the name of the the XML tag this class will leave behind as its instances are serialized.

Returns
A string containing "HashedString32"

Definition at line 158 of file hashedstring.cpp.

String Mezzanine::HashedString32::GetString ( ) const

Get the string that was used to calculate the hash.

Returns
A Mezzanine::String

Definition at line 107 of file hashedstring.cpp.

Int32 Mezzanine::HashedString32::Murmur32bit ( const String ToBeHashed)
static

Compute a MurmurA aka MurmurX86-32bit has of a string and return it.

Parameters
ToBeHashedThe string to hash
Returns
A 32 bit value approximating unique, which represents the passed string.

Definition at line 50 of file hashedstring.cpp.

bool Mezzanine::HashedString32::operator!= ( const HashedString32 Other) const

Compare The hash of this and another string for inequality.

Parameters
OtherThe other string to compare this one too.
Returns
True if the hashes are different.

Definition at line 81 of file hashedstring.cpp.

bool Mezzanine::HashedString32::operator< ( const HashedString32 Other) const

Provide a semantically useless, but quite fast sorting order for std containers based on only hashes.

Parameters
OtherThe other string to compare this one too.
Returns
true If the Hash of this is smaller than the hash of the other

Definition at line 89 of file hashedstring.cpp.

bool Mezzanine::HashedString32::operator== ( const HashedString32 Other) const

Compare The hash of this and another string for equality.

Parameters
OtherThe other string to compare this one too.
Returns
True if the hashes are the same.
Note
It is imcredibly unlikely, but this could return true in the event of a hash collision.

Definition at line 73 of file hashedstring.cpp.

bool Mezzanine::HashedString32::operator> ( const HashedString32 Other) const

Provide a semantically useless, but quite fast sorting order for std containers based on only hashes.

Parameters
OtherThe other string to compare this one too.
Returns
true If the Hash of this is larger than the hash of the other

Definition at line 96 of file hashedstring.cpp.

void Mezzanine::HashedString32::ProtoDeSerialize ( const XML::Node OneNode)

Take the data stored in an XML and overwrite this instance of this object with it.

Parameters
OneNodeand XML::Node containing the data.

Definition at line 142 of file hashedstring.cpp.

void Mezzanine::HashedString32::ProtoSerialize ( XML::Node CurrentRoot) const

Convert this class to an XML::Node ready for serialization.

Parameters
CurrentRootThe point in the XML hierarchy that all this HashedString32 should be appended to.

Definition at line 116 of file hashedstring.cpp.

void Mezzanine::HashedString32::SetString ( const String NewString)

Set a new string and recalculate its hash.

Parameters
NewStringThe data to hash and store for later use.

Definition at line 110 of file hashedstring.cpp.


The documentation for this class was generated from the following files: