TrainHash Class Reference
This class handles creation of new Hash functions. More...

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 | |
Edge * | edges |
VertexSet * | vertexSet |
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 | |||
) |
The constructor initialises the training parameters.
References Hash::depth, edges, Hash::gLength, Hash::gTable, VertexSet::next, nrOfEdges, Hash::nrOfSamples, Hash::random1, Hash::random2, Hash::randomTableLength, VertexSet::setNr, and vertexSet.
TrainHash::~TrainHash | ( | ) |
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().

int TrainHash::getIndex | ( | int * | w | ) |
- Todo:
- Docs
Reimplemented from Hash.
References Hash::depth, Hash::gLength, Hash::gTable, Hash::nrOfSamples, Hash::random1, Hash::random2, and Hash::randomTableLength.
Referenced by Shout_lm2bin::Shout_lm2bin().
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 | ) |
- Todo:
- Docs
References Hash::depth, WriteFileLittleBigEndian::fwriteEndianSafe(), Hash::gLength, Hash::gTable, Hash::nrOfSamples, Hash::random1, Hash::random2, and Hash::randomTableLength.
Referenced by Shout_lm2bin::Shout_lm2bin().

bool TrainHash::traverse | ( | ) | [protected] |
This is a helper function for finalizeHash().
References edges, Hash::gTable, VertexSet::next, nrOfEdges, Hash::nrOfSamples, Edge::vertexID_A, Edge::vertexID_B, and vertexSet.
Referenced by finalizeHash().
Member Data Documentation
Edge* TrainHash::edges [protected] |
Referenced by fillMapping(), TrainHash(), traverse(), and ~TrainHash().
int TrainHash::nrOfEdges [protected] |
Referenced by fillMapping(), initialiseMapping(), TrainHash(), and traverse().
VertexSet* TrainHash::vertexSet [protected] |
Referenced by fillMapping(), finalizeHash(), initialiseMapping(), TrainHash(), traverse(), and ~TrainHash().