OmniSketch  0.1
Oh my sketch!
OmniSketch::Hash::HashBase Class Referenceabstract

Base class for all hashing classes. More...

#include <hash.h>

Inheritance diagram for OmniSketch::Hash::HashBase:

Public Member Functions

virtual uint64_t operator() (const uint8_t *key, const int32_t len) const final
 Hash byte array. More...
 
virtual uint64_t operator() (const size_t val) const final
 Hash an integer. More...
 
template<int32_t key_len>
uint64_t operator() (const FlowKey< key_len > &flowkey) const
 Hash a flowkey. More...
 

Static Public Member Functions

static void random_seed ()
 Randomize the seed of the pseudo-randomness generator. More...
 

Detailed Description

Base class for all hashing classes.

Any derived class only has to implement a private uint64_t hash(const uint8_t *, const int32_t) const method. Note that

are automatically inherited so that they internally call hash(const uint8_t *, const int32_t) const to hash the input.

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)
};
// impl/hash.cpp
uint64_t MyHash::hash(const uint8_t *key, const int32_t len) const {
// Implementation here
}

Member Function Documentation

◆ operator()() [1/3]

template<int32_t key_len>
uint64_t OmniSketch::Hash::HashBase::operator() ( const FlowKey< key_len > &  flowkey) const
inline

Hash a flowkey.

Template Parameters
key_lenlength of flowkey
Parameters
flowkeythe flowkey to hash
Returns
hashed value of the flowkey
Attention
Do not override this function in derived classes.

◆ operator()() [2/3]

virtual uint64_t OmniSketch::Hash::HashBase::operator() ( const size_t  val) const
inlinefinalvirtual

Hash an integer.

Parameters
valinteger to hash
Returns
hashed value of the integer
Attention
Do not override this function in derived classes.

◆ operator()() [3/3]

virtual uint64_t OmniSketch::Hash::HashBase::operator() ( const uint8_t *  key,
const int32_t  len 
) const
inlinefinalvirtual

Hash byte array.

Parameters
keypointer to the byte array
lenlength of the byte array
Returns
hashed value of the byte array
Attention
Do not override this function in derived classes.

◆ random_seed()

static void OmniSketch::Hash::HashBase::random_seed ( )
inlinestatic

Randomize the seed of the pseudo-randomness generator.

Note
Currently not invoked.