![]() |
NVMLib
very early alpha
A library to optimally use a Hybrid RAM setup.
|
#include <stdbool.h>#include <stdlib.h>

Go to the source code of this file.
Macros | |
| #define | LOAD_FACTOR 0.8 |
| #define | HASH_MAP(VALUE_TYPE) VALUE_TYPE##_hash_map |
| #define | HASH_MAP_BUCKET(VALUE_TYPE) VALUE_TYPE##_hash_map_bucket |
| #define | HASH_MAP_INSERT(VALUE_TYPE) insert_into_##VALUE_TYPE##_hash_map |
| #define | HASH_MAP_FIND(VALUE_TYPE) find_in_##VALUE_TYPE##_hash_map |
| #define | HASH_MAP_CREATE(VALUE_TYPE) create_new_##VALUE_TYPE##_hash_map |
| #define | HASH_MAP_ERASE(VALUE_TYPE) erase_from_##VALUE_TYPE##_hash_map |
| #define | HASH_MAP_DESTROY(VALUE_TYPE) destroy_##VALUE_TYPE##_hash_map |
| #define | _HASH_STRUCTURE(VALUE_TYPE) |
| #define | DECLARE_HASHMAP(VALUE_TYPE) |
| Declaration of HashMap of a given type. More... | |
| #define | DEFINE_HASHMAP(VALUE_TYPE, CMP, GET_HASH, FREE, REALLOC) |
| Definition of the declared HashMap. More... | |
| #define | HASH_MAP_PRINT(VALUE_TYPE) print_##VALUE_TYPE##_hash_map |
| For Debug purposes. More... | |
| #define | HASH_MAP_PRINT_FUNC(VALUE_TYPE, PRINT_OBJ_FUNC) |
Typedefs | |
| typedef __uint128_t | uint128_t |
| typedef __uint64_t | uint64_t |
| typedef __uint32_t | uint32_t |
| typedef __uint16_t | uint16_t |
| typedef __uint8_t | uint8_t |
Enumerations | |
| enum | HashMapDuplicateResolution { HMDR_FAIL = 0, HMDR_FIND, HMDR_REPLACE, HMDR_SWAP } |
| enum | HashMapResult { HMR_FAILED = 0, HMR_FOUND, HMR_REPLACED, HMR_SWAPPED, HMR_INSERTED } |
Functions | |
| static size_t | next_power_of_two (size_t i) |
| static size_t | index_for_hash (size_t hash, size_t shift, size_t pow_of_two) |
| Fibonacci hashing 11400714819323198485ull = 2^64 / golden_ratio. More... | |
This file provides a generic hashmap stored in DRAM.
This hashmap will be a chaining hashmap, with load factor = 0.8 no. of buckets = power of 2 hash function for distribution = fibonacci hashing hash function for hashing the object = User provided
Definition in file hashmap.h.
| #define _HASH_STRUCTURE | ( | VALUE_TYPE | ) |
| #define DECLARE_HASHMAP | ( | VALUE_TYPE | ) |
| #define DEFINE_HASHMAP | ( | VALUE_TYPE, | |
| CMP, | |||
| GET_HASH, | |||
| FREE, | |||
| REALLOC | |||
| ) |
Definition of the declared HashMap.
| VALUE_TYPE | : Type of stored entries. It has to be Typedef'd name. |
| CMP | : int (*cmp)(VALUE_TYPE *left, VALUE_TYPE *right). Could easily be a macro. Must return 0 if and only if *left equals *right. |
| GET_HASH | : inttype (*getHash)(VALUE_TYPE *entry). Could easily be a macro. |
| FREE | : free() to use |
| REALLOC | : realloc() to use. |
| #define HASH_MAP_BUCKET | ( | VALUE_TYPE | ) | VALUE_TYPE##_hash_map_bucket |
| #define HASH_MAP_CREATE | ( | VALUE_TYPE | ) | create_new_##VALUE_TYPE##_hash_map |
| #define HASH_MAP_DESTROY | ( | VALUE_TYPE | ) | destroy_##VALUE_TYPE##_hash_map |
| #define HASH_MAP_ERASE | ( | VALUE_TYPE | ) | erase_from_##VALUE_TYPE##_hash_map |
| #define HASH_MAP_FIND | ( | VALUE_TYPE | ) | find_in_##VALUE_TYPE##_hash_map |
| #define HASH_MAP_INSERT | ( | VALUE_TYPE | ) | insert_into_##VALUE_TYPE##_hash_map |
| #define HASH_MAP_PRINT | ( | VALUE_TYPE | ) | print_##VALUE_TYPE##_hash_map |
| #define HASH_MAP_PRINT_FUNC | ( | VALUE_TYPE, | |
| PRINT_OBJ_FUNC | |||
| ) |
| enum HashMapResult |
|
inlinestatic |