TrainHash Class Reference

This class handles creation of new Hash functions. More...

Inheritance diagram for TrainHash:

List of all members.


Public Member Functions

 TrainHash (int nrOfS, int d, int nrOfW)
 ~TrainHash ()
void storeHash (FILE *file)
void initialiseMapping ()
bool fillMapping (int *w)
void finalizeHash ()
int getIndex (int *w)

Protected Member Functions

bool traverse ()

Protected Attributes

Edgeedges
VertexSetvertexSet
int nrOfEdges

Detailed Description

This class handles creation of new Hash functions.

The theory from: ["An Optimal Algorithm for Generating Minimal Perfect Hash Functions", Z.J. Czech, G. Havas and B.S. Majewski]. is used to construct and use the hash function. This class only loads, stores and uses the hash function. The class TrainHash is able to create new hash functions.


Constructor & Destructor Documentation

TrainHash::TrainHash ( int  nrOfS,
int  d,
int  nrOfW 
)

TrainHash::~TrainHash (  ) 

The destructor deletes all claimed memory.

References edges, and vertexSet.


Member Function Documentation

bool TrainHash::fillMapping ( int *  w  ) 

Given the by initialiseMapping() random generated numbers, the mapping is filled. If the mapping is not a-cyclic (and therefor it is useless), this method will return false. If a succesfull mapping was possible, it will return true.

References Hash::depth, edges, Hash::gLength, Hash::gTable, VertexSet::next, nrOfEdges, Hash::nrOfSamples, Hash::random1, Hash::random2, Hash::randomTableLength, VertexSet::setNr, Edge::vertexID_A, Edge::vertexID_B, and vertexSet.

Referenced by Shout_lm2bin::Shout_lm2bin().

void TrainHash::finalizeHash (  ) 

This method may be used when fillMapping() has returned true for all samples. It will fill the gTable table with the hash appropriate hash indices.

References Hash::gLength, Hash::gTable, VertexSet::next, traverse(), and vertexSet.

Referenced by Shout_lm2bin::Shout_lm2bin().

Here is the call graph for this function:

int TrainHash::getIndex ( int *  w  ) 

void TrainHash::initialiseMapping (  ) 

This method deletes all existing data and will generate new random numbers for a new mapping.

References Hash::depth, Hash::gLength, Hash::gTable, VertexSet::next, nrOfEdges, Hash::random1, Hash::random2, Hash::randomTableLength, VertexSet::setNr, and vertexSet.

Referenced by Shout_lm2bin::Shout_lm2bin().

void TrainHash::storeHash ( FILE *  file  ) 

bool TrainHash::traverse (  )  [protected]


Member Data Documentation