Defines for the Order Preserving Minimal Perfect Hash Map.
More...
#include <stdint.h>
#include <stdlib.h>
|
|
typedef const char *(* | opmphmGetString) (void *) |
| | Only needed for Initialisation.
|
| |
|
| double | opmphmMinC (void) |
| | Graph functions. More...
|
| |
| OpmphmGraph * | opmphmGraphNew (Opmphm *opmphm, size_t n, double c) |
| | Allocates and initializes the OpmphmGraph. More...
|
| |
| void | opmphmGraphDel (OpmphmGraph *graph) |
| | Deletes the OpmphmGraph. More...
|
| |
| int | opmphmMapping (Opmphm *opmphm, OpmphmGraph *graph, OpmphmInit *init, size_t n) |
| | Build functions. More...
|
| |
| int | opmphmAssignment (Opmphm *opmphm, OpmphmGraph *graph, size_t n, int defaultOrder) |
| | Assigns the vertices of the r-partite hypergraph. More...
|
| |
| size_t | opmphmLookup (Opmphm *opmphm, const void *name) |
| | Lookup functions. More...
|
| |
| Opmphm * | opmphmNew (void) |
| | Basic functions. More...
|
| |
| void | opmphmDel (Opmphm *opmphm) |
| | Deletes the OPMPHM. More...
|
| |
| void | opmphmClear (Opmphm *opmphm) |
| | Clears the OPMPHM. More...
|
| |
| int | opmphmIsEmpty (Opmphm *opmphm) |
| | Determines if the OPMPHM is Empty. More...
|
| |
|
uint32_t | opmphmHashfunction (const void *key, size_t length, uint32_t initval) |
| | Hash function By Bob Jenkins, May 2006 http://burtleburtle.net/bob/c/lookup3.c Original name: hashlitte.
|
| |
Defines for the Order Preserving Minimal Perfect Hash Map.
- Copyright
- BSD License (see doc/COPYING or https://www.libelektra.org)
◆ OPMPHMR_PARTITE
| #define OPMPHMR_PARTITE 3 |
The Order Preserving Minimal Perfect Hash Map (OPMPHM) maps each element to an edge in an r-partite hypergraph.
The r-partite hypergraph consist of OPMPHMR_PARTITE components, each component has Opmphm->componentSize vertices. An edge connects OPMPHMR_PARTITE vertices, each one in separate components of the r-partite hypergraph. The number of vertices in one component of the r-partite hypergraph (Opmphm->componentSize) is calculated during opmphmGraphNew () the following way:
Note that c must have a minimal value in order to generate acyclic r-partite hypergraphs. The minimal value of c depends on OPMPHMR_PARTITE and is provided by the function opmphmMinC ().
The finals size of the opmphm (Opmphm->graph) is: Opmphm->componentSize * OPMPHMR_PARTITE
◆ opmphmAssignment()
| int opmphmAssignment |
( |
Opmphm * |
opmphm, |
|
|
OpmphmGraph * |
graph, |
|
|
size_t |
n, |
|
|
int |
defaultOrder |
|
) |
| |
Assigns the vertices of the r-partite hypergraph.
Allocs the memory for the final OPMPHM Opmphm->graph. Uses the remove sequence OpmphmGraph->removeOrder, generated during cycle check, to assign each vertex. Either with OpmphmEdge->order or the default order, default is the order of OpmphmInit->data.
- Parameters
-
| opmphm | the OPMPHM |
| graph | the OpmphmGraph |
| n | the number of elements |
| defaultOrder | boolean flag |
- Return values
-
| 0 | on success |
| -1 | on memory error |
◆ opmphmClear()
| void opmphmClear |
( |
Opmphm * |
opmphm | ) |
|
Clears the OPMPHM.
Clears and frees all internal memory of Opmphm, but not the Opmphm instance.
- Parameters
-
◆ opmphmDel()
| void opmphmDel |
( |
Opmphm * |
opmphm | ) |
|
Deletes the OPMPHM.
Clears and frees all memory in Opmphm.
- Parameters
-
◆ opmphmGraphDel()
| void opmphmGraphDel |
( |
OpmphmGraph * |
graph | ) |
|
Deletes the OpmphmGraph.
- Parameters
-
◆ opmphmGraphNew()
| OpmphmGraph* opmphmGraphNew |
( |
Opmphm * |
opmphm, |
|
|
size_t |
n, |
|
|
double |
c |
|
) |
| |
Allocates and initializes the OpmphmGraph.
The OpmphmGraph represents a r-partite hypergraph. Calculates also the size of one partition in the r-partite hypergraph and stores it in opmphm->componentSize.
- Parameters
-
| opmphm | the OPMPHM |
| n | the number of elements |
| c | space influencing parameter |
- Return values
-
| OpmphmGraph | * success |
| NULL | memory error |
◆ opmphmIsEmpty()
| int opmphmIsEmpty |
( |
Opmphm * |
opmphm | ) |
|
Determines if the OPMPHM is Empty.
Empty means opmphm->size is 0.
- Parameters
-
- Return values
-
◆ opmphmLookup()
| size_t opmphmLookup |
( |
Opmphm * |
opmphm, |
|
|
const void * |
name |
|
) |
| |
Lookup functions.
Lookup functions.
- Parameters
-
| opmphm | the OPMPHM |
| name | the name of the element |
- Return values
-
| size_t | the order of the element. |
◆ opmphmMapping()
| int opmphmMapping |
( |
Opmphm * |
opmphm, |
|
|
OpmphmGraph * |
graph, |
|
|
OpmphmInit * |
init, |
|
|
size_t |
n |
|
) |
| |
Build functions.
Build functions.
Sets the seeds for the opmphmHashfunctions, OpmphmInit->initSeed will be changed. Inserts each element as edge in the r-partite hypergraph and checks if the graph contains a cycle.
- Parameters
-
| opmphm | the OPMPHM |
| graph | the OpmphmGraph |
| init | the OpmphmInit |
| n | the number of elements |
- Return values
-
| 0 | on success |
| -1 | mapping not possible |
◆ opmphmMinC()
| double opmphmMinC |
( |
void |
| ) |
|
Graph functions.
Graph functions.
This minimal values come from Fabiano Cupertino Botelho, Near-Optimal Space Perfect Hashing Algorithms, 2008.
- Return values
-
◆ opmphmNew()
Basic functions.
Basic functions.
The returned OPMPHM instance is Empty.
- Return values
-
| Opmphm | * success |
| NULL | memory error |