Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
|
Go to the documentation of this file.
160 HashBucket *(*ht_create_buckets_fn) (
const uint32 num_buckets);
204 const uint8 load_percentage,
205 uint32 (*hash_fn) (
const void *
const key_p),
206 HashBucket *(*create_buckets_fn) (
const uint32 num_buckets),
207 void (*free_bucket_fn) (
HashBucket *
const bucket_p),
208 bool (*fill_bucket_fn) (
HashBucket *
const bucket_p,
const void *
const key_p,
const void *
const value_p),
209 bool (*compare_keys_fn) (
const void *
const bucket_key_p,
const void *
const key_p),
211 bool (*save_bucket_fn) (
const HashBucket *
const bucket_p, FILE *out_f));
void RemoveFromHashTable(HashTable *const hash_table_p, const void *const key_p)
For a given key, empty the corresponding bucket in a HashTable.
bool SaveHashTable(const HashTable *const table_p, const char *const filename_s, int(*compare_fn)(const void *v0_p, const void *v1_p))
Save a HashTable to a file.
HashBucket * CreateDeepCopyHashBuckets(const uint32 num_buckets)
Create an array of HashBuckets where each one will make a deep copy of the key and value when they ar...
MEM_FLAG hb_owns_key
Can the HashBucket free its key or is the memory owned by another process?
Definition: hash_table.h:54
uint32(* ht_hash_fn)(const void *)
Function for calculating the hashed value of a HashBucket key.
Definition: hash_table.h:157
uint32 ht_load_limit
The ht_capacity * ht_load.
Definition: hash_table.h:151
bool(* ht_save_bucket_fn)(const HashBucket *const bucket_p, FILE *out_f)
Function for saving the HashBuckets in this HashTable to a file.
Definition: hash_table.h:175
uint32 hb_hashed_key
The hashed value of this HashBucket key.
Definition: hash_table.h:45
MEM_FLAG
An enum specifying the particular status of a piece of dynamically allocated memory for a particular ...
Definition: memory_allocations.h:38
bool(* ht_fill_bucket_fn)(HashBucket *const bucket_p, const void *const key_p, const void *const value_p)
Function for filling a HashBucket.
Definition: hash_table.h:166
HashTable * AllocateHashTable(const uint32 initial_size, const uint8 load_percentage, uint32(*hash_fn)(const void *const key_p), HashBucket *(*create_buckets_fn)(const uint32 num_buckets), void(*free_bucket_fn)(HashBucket *const bucket_p), bool(*fill_bucket_fn)(HashBucket *const bucket_p, const void *const key_p, const void *const value_p), bool(*compare_keys_fn)(const void *const bucket_key_p, const void *const key_p), void(*print_bucket_fn)(const HashBucket *const bucket_p, OutputStream *const stream_p), bool(*save_bucket_fn)(const HashBucket *const bucket_p, FILE *out_f))
Allocate a new HashTable.
HashBucket * CreateShadowUseHashBuckets(const uint32 num_buckets)
Create an array of HashBuckets where each one will make shadow use the key and value when they are pu...
MEM_FLAG hb_owns_value
Can the HashBucket free its value or is the memory owned by another process?
Definition: hash_table.h:57
void ClearHashTable(HashTable *const hash_table_p)
Clear a HashTable.
const void * hb_key_p
The key.
Definition: hash_table.h:48
uint8 ht_load
How full to let the hash table get before rehashing, between 0 and 100.
Definition: hash_table.h:148
uint32 ht_capacity
The actual number of HashBucket slots in the HashTable.
Definition: hash_table.h:145
HashBucket * CreateDeepCopyKeysShallowCopyValueHashBuckets(const uint32 num_buckets)
Create an array of HashBuckets where each one will make a deep copy of the key and a shallow copy of ...
HashTable * CopyHashTable(const HashTable *const src_table_p, const bool deep_copy_if_necessary)
Copy a HashTable.
void PrintHashTable(const HashTable *const hash_table_p, OutputStream *const stream_p)
Print out a HashTable to a given stream.
A datatype for holding a key-value pair along with the hashed value of the key.
Definition: hash_table.h:42
const void * GetFromHashTable(const HashTable *const hash_table_p, const void *const key_p)
For a given key, get the value from a HashTable.
void(* ht_free_bucket_fn)(HashBucket *const bucket_p)
Function for feeing a HashBucket.
Definition: hash_table.h:163
bool PutInHashTable(HashTable *const hash_table_p, const void *const key_p, const void *const value_p)
Put a key-value pair in the HashTable.
uint32 ht_size
The number of valid HashBuckets in the HashTable.
Definition: hash_table.h:142
HashBucket * CreateHashBuckets(const uint32 num_buckets, const MEM_FLAG key_mem_flag, const MEM_FLAG value_mem_flag)
Function for creating the HashBuckets.
HashBucket * CreateShallowCopyHashBuckets(const uint32 num_buckets)
Create an array of HashBuckets where each one will make a shallow copy of the key and value when they...
HashBucket * ht_buckets_p
The HashBuckets.
Definition: hash_table.h:154
void FreeKeysIndex(void **index_pp)
Free an index array previously returned by a call to GetKeysIndexFromHashTable.
bool IsValidHashBucket(const HashBucket *const bucket_p)
Does the HashBucket contain a valid key-value pair.
uint32 GetHashTableSize(const HashTable *const table_p)
Get the number of entries in a HashTable.
void FreeHashBucket(HashBucket *const bucket_p)
Function for freeing a HashBucket.
bool LoadHashTable(HashTable *const table_p, char *current_path_s, const char *const filename_s)
Load the contents of a previously-saved HashTable file into a HashTable.
void FreeHashTable(HashTable *const hash_table_p)
Free a HashTable.
const void * hb_value_p
The value.
Definition: hash_table.h:51
An datatype to abstract out the process of writing log and error messages to the appropriate processe...
Definition: streams.h:106
#define GRASSROOTS_UTIL_API
Definition: grassroots_util_library.h:47
void(* ht_print_bucket_fn)(const HashBucket *const bucket_p, OutputStream *const stream_p)
Function for printing out the HashBuckets in this HashTable.
Definition: hash_table.h:172
A container using HashBuckets to allow for fast lookup of key-value pairs.
Definition: hash_table.h:139
void ** GetKeysIndexFromHashTable(const HashTable *const hash_table_p)
Get a new array with pointers to each of the keys in a given HashTable.
bool(* ht_compare_keys_fn)(const void *const bucket_key_p, const void *const key_p)
Function for comparing the keys of two HashBuckets.
Definition: hash_table.h:169