Filter Library | Camera | Interface Physics |
#include <ToolHashBuilder.h>
Example.
char character = 'a'; int integer = 0; char* string = ""; typedef CHashBuilder::ValueType HashType; HashType LastHash = 0; HashType ComputeHash() { CHashBuilder NewHash; return NewHash = character, integer, string; } bool SomethingChanged() { return ComputeHash() != LastHash; } void MyInitialize() { LastHash = ComputeHash(); } void MyAction() { if ( SomethingChanged() ) { // act on changes and save new hash value LastHash = ComputeHash(); } else { ; // no action required } }
Class CHashBuilder was inspired on the article "A Checksum Algorithm" by Joseph M. Newcomer [CHECKSUM].
Class CHashBuilder uses the hash function by P.J. Weinberger from the dragon book [Aho et al., 1986].
Definition at line 85 of file ToolHashBuilder.h.
Public Types | |
typedef CHashBuilder | Self |
this type. | |
typedef unsigned char | uchar |
unsigned character type; | |
typedef unsigned int | uint |
unsigned integer type. | |
typedef unsigned long | ulong |
unsigned long integer type. | |
typedef ulong | ValueType |
the hash type. | |
Public Member Functions | |
Operators | |
Self & | operator= (char c) |
assign a character. | |
Self & | operator= (int i) |
assign an integer. | |
Self & | operator= (long int i) |
assign a long integer. | |
Self & | operator= (unsigned char c) |
assign an unsigned character. | |
Self & | operator= (uint i) |
assign an unsigned integer. | |
Self & | operator= (ulong i) |
assign an unsigned long integer. | |
Self & | operator= (float f) |
assign a float. | |
Self & | operator= (double d) |
assign a double. | |
Self & | operator= (const char *s) |
assign a C-string. | |
Self & | operator, (char chr) |
add a character. | |
Self & | operator, (uchar chr) |
add a unsigned character. | |
Self & | operator, (int i) |
add an integer. | |
Self & | operator, (uint i) |
add an unsigned integer. | |
Self & | operator, (long i) |
add a long integer. | |
Self & | operator, (ulong i) |
add an unsigned long integer. | |
Self & | operator, (float f) |
add a float. | |
Self & | operator, (double d) |
add a double. | |
Self & | operator, (const char *s) |
add a C-string. | |
operator ValueType () const | |
convert to ValueType, return hash value; alias for GetHash(). | |
Accessors | |
ValueType | GetHash () const |
the current hash value. | |
Mutators | |
void | Clear () |
clear the hash value. | |
Self & | Add (unsigned char chr) |
add an unsigned character to the hash (P.J. | |
Self & | Add (char chr) |
add a character to the hash. | |
Self & | Add (int i) |
add an integer to the hash. | |
Self & | Add (uint i) |
add an unsigned integer to the hash. | |
Self & | Add (long i) |
add a long to the hash. | |
Self & | Add (ulong i) |
add an unsigned long to the hash. | |
Self & | Add (float f) |
add a float to the hash. | |
Self & | Add (double d) |
add a float to the hash. | |
Self & | Add (const char *string) |
add a C-string to the hash. | |
Private Attributes | |
ValueType | m_hash |
Self& CHashBuilder::Add | ( | unsigned char | chr | ) | [inline] |
Weinberger's hash, hash_pjw).
Definition at line 390 of file ToolHashBuilder.h.
References m_hash.
Referenced by Add(), CHashBuilder(), operator,(), and operator=().