Phoenix
Object-oriented orthogonally persistent operating system
Public Member Functions | Static Public Member Functions
Hash Class Reference

This class is the primary tool for calculating lookup (non-cryptographic) hashes in Phoenix. More...

#include <hash.h>

List of all members.

Public Member Functions

 Hash (u32 initial=0)
 Create hash object.
void Reset (u32 initial=0)
 Reset the calculator state to the initial one.
void Feed (const void *data, size_t size)
 Feed input data to hash calculator.
u32 Get32 ()
 Get 32-bits hash value based on data fed so far.
u64 Get64 ()
 Get 64-bits hash value based on data fed so far.
 operator u32 ()
 Get 32-bits hash value based on data fed so far.
 operator u64 ()
 Get 64-bits hash value based on data fed so far.
size_t GetLength ()
 Get total length of data fed to the calculator input so far.

Static Public Member Functions

static void Mix (u32 &a, u32 &b, u32 &c)
 Apply hash reversible mix operation to three 32-bits words.
static void Final (u32 &a, u32 &b, u32 &c)
 Final mixing of three 32-bits words.

Detailed Description

This class is the primary tool for calculating lookup (non-cryptographic) hashes in Phoenix.

It is based on Bob Jenkins hash algorithm (lookup3).


Constructor & Destructor Documentation

Hash::Hash ( u32  initial = 0) [inline]

Create hash object.

Parameters:
initialInitial value for a hash. It can be used as salt.

Member Function Documentation

void Hash::Feed ( const void *  data,
size_t  size 
)

Feed input data to hash calculator.

This method can be called any number of times providing next portion of input data. At any time Get32 or Get64 methods can be called to get current value of hash.

Parameters:
dataNext portion of input data.
sizeSize in bytes of provided data.
void Hash::Final ( u32 a,
u32 b,
u32 c 
) [static]

Final mixing of three 32-bits words.

Parameters:
aThe first word.
bThe second word.
cThe third word. Result is returned in this argument.
u32 Hash::Get32 ( ) [inline]

Get 32-bits hash value based on data fed so far.

Returns:
32-bits hash value.
u64 Hash::Get64 ( ) [inline]

Get 64-bits hash value based on data fed so far.

Returns:
64-bits hash value.
size_t Hash::GetLength ( ) [inline]

Get total length of data fed to the calculator input so far.

Returns:
Total length of data fed to the calculator input so far
void Hash::Mix ( u32 a,
u32 b,
u32 c 
) [static]

Apply hash reversible mix operation to three 32-bits words.

Parameters:
aThe first word.
bThe second word.
cThe third word.
Hash::operator u32 ( ) [inline]

Get 32-bits hash value based on data fed so far.

This operation is not destructive - data still can be fed on input to get hash values incrementally.

Returns:
32-bits hash value.
Hash::operator u64 ( ) [inline]

Get 64-bits hash value based on data fed so far.

Returns:
64-bits hash value.
void Hash::Reset ( u32  initial = 0) [inline]

Reset the calculator state to the initial one.

Parameters:
initialInitial value for a hash. It can be used as salt.

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines