open_address_hash.h
Go to the documentation of this file.
1 /******************************************************************************/
35 /******************************************************************************/
36 
37 #if !defined(OPEN_ADDRESS_H_)
38 #define OPEN_ADDRESS_H_
39 
40 #if defined(__cplusplus)
41 extern "C" {
42 #endif
43 
44 #include <string.h>
45 #include <stdio.h>
46 
47 #include "../dictionary_types.h"
48 #include "./../dictionary.h"
50 
51 #if defined(ARDUINO)
52 #include "./../../serial/serial_c_iface.h"
53 #endif
54 
55 #include "../../key_value/kv_system.h"
56 
57 #define ION_EMPTY -1
58 #define ION_DELETED -2
59 #define ION_IN_USE -3
60 #define SIZEOF(STATUS) 1
61 
65 typedef struct hashmap ion_hashmap_t;
66 
70 struct hashmap {
72  int map_size;
76  int (*compute_hash)(
77  ion_hashmap_t *,
78  ion_key_t,
79  int
80  );
81 
84  char *entry;
85 };
86 
105 ion_err_t
108  ion_hash_t (*hashing_function)(ion_hashmap_t *, ion_key_t, int),
109  ion_key_type_t key_type,
110  ion_key_size_t key_size,
111  ion_value_size_t value_size,
112  int size
113 );
114 
124 ion_err_t
126  ion_hashmap_t *hash_map
127 );
128 
141 int
143  ion_hash_t num,
144  int size
145 );
146 
167 oah_insert(
168  ion_hashmap_t *hash_map,
169  ion_key_t key,
170  ion_value_t value
171 );
172 
188 oah_update(
189  ion_hashmap_t *hash_map,
190  ion_key_t key,
191  ion_value_t value
192 );
193 
207 ion_err_t
209  ion_hashmap_t *hash_map,
210  ion_key_t key,
211  int *location
212 );
213 
226 oah_delete(
227  ion_hashmap_t *hash_map,
228  ion_key_t key
229 );
230 
247 oah_get(
248  ion_hashmap_t *hash_map,
249  ion_key_t key,
250  ion_value_t value
251 );
252 
266  ion_hashmap_t *hashmap,
267  ion_key_t key,
268  int size_of_key
269 );
270 
271 #if defined(__cplusplus)
272 }
273 #endif
274 
275 #endif
int ion_hash_t
The position in the hashmap.
int(* compute_hash)(ion_hashmap_t *, ion_key_t, int)
ion_status_t oah_get(ion_hashmap_t *hash_map, ion_key_t key, ion_value_t value)
Locates the record if it exists.
ion_hash_t oah_compute_simple_hash(ion_hashmap_t *hashmap, ion_key_t key, int size_of_key)
A simple hashing algorithm implementation.
enum ION_KEY_TYPE ion_key_type_t
This is the available key types for ION_DB. All types will be based on system defines.
char * entry
Struct used to maintain an instance of an in memory hashmap.
int ion_value_size_t
The size (length) of a dictionary value in bytes.
Definition: kv_system.h:256
ion_err_t oah_initialize(ion_hashmap_t *hashmap, ion_hash_t(*hashing_function)(ion_hashmap_t *, ion_key_t, int), ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size, int size)
This function initializes an open address in memory hash map.
ion_dictionary_parent_t super
#define key(k)
Definition: bpp_tree.c:75
This is the super type for all dictionaries.
char ion_err_t
The error type used to store error codes.
Definition: kv_system.h:226
void * ion_key_t
A dictionary key.
Definition: kv_system.h:241
void * ion_value_t
A dictionary value.
Definition: kv_system.h:246
int oah_get_location(ion_hash_t num, int size)
Returns the theoretical location of item in hashmap.
ion_err_t oah_destroy(ion_hashmap_t *hash_map)
Destroys the map in memory.
ion_status_t oah_insert(ion_hashmap_t *hash_map, ion_key_t key, ion_value_t value)
Insert record into hashmap.
ion_err_t oah_find_item_loc(ion_hashmap_t *hash_map, ion_key_t key, int *location)
Locates item in map.
ion_status_t oah_delete(ion_hashmap_t *hash_map, ion_key_t key)
Deletes item from map.
ion_status_t oah_update(ion_hashmap_t *hash_map, ion_key_t key, ion_value_t value)
Updates a value in the map.
char ion_write_concern_t
A type for write concern information used by hash table based dictionaries which limit insert/update ...
int ion_key_size_t
The size (length) of a dictionary key in bytes.
Definition: kv_system.h:251
This file includes common components for oadictionary and oahash.
ion_write_concern_t write_concern
A status object that describes the result of a dictionary operation.
Definition: kv_system.h:290