OmniSketch  0.1
Oh my sketch!
OmniSketch::Hash Namespace Reference

Warehouse of hashing classes. More...

Classes

class  AwareHash
 Aware hash. More...
 
class  HashBase
 Base class for all hashing classes. More...
 

Detailed Description

Warehouse of hashing classes.

All hashing classes in this warehouse are capable of hashing flowkey, integer and byte array to an uint64_t or an uint32_t value (implementation-defined). To craft a new hashing class, please inherit from HashBase, and the derived class only has to provide a simple interface looked exactly like uint64_t hash(const uint8_t *key, const int32_t len) const; (also a pure virtual function in HashBase). See the example below.

Example

// hash.h (this file)
class MyHash: public HashBase {
private:
// Any internal data and methods
uint64_t hash(const uint8_t *key, const int32_t len) const;
public:
// Constructors & destructors (if needed)
};
// src/hash.cpp
uint64_t MyHash::hash(const uint8_t *key, const int32_t len) const {
// Implementation here
}
Note
The reason why uint8_t *, rather than int8_t * or char *, is chosen for byte array is that multitudinous hash functions (if not all) are built upon unsigned integers.
See also
HashBase