/** Limited-scope, fast implementation of a bi-directional hash table. * * This data structure holds an array of key-value pairs. It is append-only. * * A key is the result of a hash function applied to the value, and keys are * unique within an index. Hence, both keys and values are uniqure and lookups * can be done both ways. * * A value is a pointer to a `LSUP_SerTerm` structure. Comparison for * uniqueness is done by comparing the hashes/keys. * * To find a key by its value, it is sufficient to apply the hash function to * the value without having to look up the table. */ #include "structures/buffer.h" #include "model/rdf/term.h" typedef struct Index LSUP_Index; LSUP_Index *LSUP_index_new(size_t capacity); /** * Add a key/value pair. The key must be calculated in advance. * * This function takes ownership of the serialized term. */ int LSUP_index_add_pair(LSUP_Index *idx, LSUP_Key key, LSUP_SerTerm *sterm); /** * Add a term and automatically calculate the key. * * This function takes ownership of the serialized term. */ int LSUP_index_add(LSUP_Index *idx, LSUP_SerTerm *sterm); LSUP_SerTerm *LSUP_index_lookup(LSUP_Index *idx, LSUP_Key key); void LSUP_index_free(LSUP_Index *idx);