Detailed Description
Special hashmap for DP-border Steiner tree algorithm.
modified version of https://github.com/sheredom/hashmap.h
Definition in file dpborder_hashmap.h.
Go to the source code of this file.
Data Structures | |
struct | hashmap_element_s |
struct | hashmap_s |
Macros | |
#define | HASHMAP_USED |
#define | HASHMAP_MAX_CHAIN_LENGTH (8) |
#define | HASHMAP_CAST(type, x) ((type)x) |
#define | HASHMAP_PTR_CAST(type, x) ((type)x) |
#define | HASHMAP_NULL 0 |
Typedefs | |
typedef struct hashmap_s | DPBHASHMAP |
Functions | |
static SCIP_RETCODE | hashmap_create (const unsigned initial_size, const char *keyarr, struct hashmap_s *const out_hashmap) HASHMAP_USED |
Create a hashmap. More... | |
static void | hashmap_updateKeyarr (const char *keyarr, struct hashmap_s *out_hashmap) HASHMAP_USED |
static int | hashmap_putcheck (struct hashmap_s *const hashmap, int key_position, const unsigned len, int value) HASHMAP_USED |
Put an element into the hashmap. More... | |
static void | hashmap_put (struct hashmap_s *const hashmap, int position, const unsigned len, int value) HASHMAP_USED |
static int | hashmap_get (const struct hashmap_s *const hashmap, int position, const unsigned len) HASHMAP_USED |
Get an element from the hashmap. More... | |
static int | hashmap_remove (struct hashmap_s *const hashmap, int position, const unsigned len) HASHMAP_USED |
Remove an element from the hashmap. More... | |
static int | hashmap_iterate_pairs (struct hashmap_s *const hashmap, struct hashmap_s *const hashmap_new) HASHMAP_USED |
Iterate over all the elements in a hashmap. More... | |
static unsigned | hashmap_num_entries (const struct hashmap_s *const hashmap) HASHMAP_USED |
Get the size of the hashmap. More... | |
static SCIP_Bool | hashmap_isEmpty (const struct hashmap_s *const hashmap) HASHMAP_USED |
static void | hashmap_destroy (struct hashmap_s *const hashmap) HASHMAP_USED |
Destroy the hashmap. More... | |
static unsigned | hashmap_crc32_helper (const char *const s, const unsigned len) HASHMAP_USED |
static unsigned | hashmap_hash_helper_int_helper (const struct hashmap_s *const m, const char *const keystring, const unsigned len) HASHMAP_USED |
static int | hashmap_hash_helper (const struct hashmap_s *const m, int position, const unsigned len, unsigned *const out_index) HASHMAP_USED |
static int | hashmap_rehash_iterator (struct hashmap_s *const m_new, struct hashmap_element_s *const e) HASHMAP_USED |
static int | hashmap_rehash_helper (struct hashmap_s *const m) HASHMAP_USED |
static int | hashmap_match_helper (const struct hashmap_element_s *const element, const char *const key, const char *const keyarr, const unsigned len) |
Macro Definition Documentation
◆ HASHMAP_USED
#define HASHMAP_USED |
Definition at line 73 of file dpborder_hashmap.h.
◆ HASHMAP_MAX_CHAIN_LENGTH
#define HASHMAP_MAX_CHAIN_LENGTH (8) |
Definition at line 93 of file dpborder_hashmap.h.
Referenced by hashmap_get(), hashmap_hash_helper(), and hashmap_remove().
◆ HASHMAP_CAST
Definition at line 189 of file dpborder_hashmap.h.
Referenced by hashmap_crc32_helper(), and hashmap_create().
◆ HASHMAP_PTR_CAST
Definition at line 190 of file dpborder_hashmap.h.
◆ HASHMAP_NULL
#define HASHMAP_NULL 0 |
Definition at line 191 of file dpborder_hashmap.h.
Typedef Documentation
◆ DPBHASHMAP
typedef struct hashmap_s DPBHASHMAP |
Function Documentation
◆ hashmap_create()
|
static |
Create a hashmap.
- Parameters
-
initial_size The initial size of the hashmap. Must be a power of two. out_hashmap The storage for the created hashmap. keyarr Array with keys
- Returns
- On success 0 is returned.
Note that the initial size of the hashmap must be a power of two, and creation of the hashmap will fail if this is not the case.
Definition at line 201 of file dpborder_hashmap.h.
References hashmap_s::elements, HASHMAP_CAST, hashmap_s::keyarray, SCIP_ERROR, SCIP_OKAY, hashmap_s::size, and hashmap_s::table_size.
Referenced by dpborder_solve(), and hashmap_rehash_helper().
◆ hashmap_updateKeyarr()
|
static |
Definition at line 223 of file dpborder_hashmap.h.
References hashmap_s::keyarray.
Referenced by initSolve(), and partitionTryRealloc().
◆ hashmap_putcheck()
|
static |
Put an element into the hashmap.
- Parameters
-
hashmap The hashmap to insert into. key_position The string key position to use. len The length of the string key. value The value to insert.
- Returns
- On success 0 is returned.
The key string slice is not copied when creating the hashmap entry, and thus must remain a valid pointer until the hashmap entry is removed or the hashmap is destroyed.
Definition at line 232 of file dpborder_hashmap.h.
References hashmap_s::elements, hashmap_hash_helper(), hashmap_rehash_helper(), hashmap_element_s::in_use, hashmap_element_s::key_len, hashmap_element_s::key_position, hashmap_s::size, and hashmap_element_s::value.
Referenced by hashmap_rehash_iterator().
◆ hashmap_put()
|
static |
Definition at line 260 of file dpborder_hashmap.h.
References hashmap_s::elements, hashmap_hash_helper(), hashmap_rehash_helper(), hashmap_element_s::in_use, hashmap_element_s::key_len, hashmap_element_s::key_position, hashmap_s::size, and hashmap_element_s::value.
Referenced by dpborder_partGetIdxNew(), and dpborder_partGetIdxNewExclusive().
◆ hashmap_get()
|
static |
Get an element from the hashmap.
- Parameters
-
hashmap The hashmap to get from. position The string key position to use. len The length of the string key.
- Returns
- The previously set element, or NULL if none exists.
Definition at line 285 of file dpborder_hashmap.h.
References hashmap_s::elements, hashmap_hash_helper_int_helper(), hashmap_match_helper(), HASHMAP_MAX_CHAIN_LENGTH, hashmap_element_s::in_use, hashmap_s::keyarray, hashmap_s::table_size, and hashmap_element_s::value.
Referenced by dpborder_partGetIdxNew(), and dpborder_partGetIdxNewExclusive().
◆ hashmap_remove()
|
static |
Remove an element from the hashmap.
- Parameters
-
hashmap The hashmap to remove from. position The string key position to use. len The length of the string key.
- Returns
- On success 0 is returned.
Definition at line 312 of file dpborder_hashmap.h.
References hashmap_s::elements, hashmap_hash_helper_int_helper(), hashmap_match_helper(), HASHMAP_MAX_CHAIN_LENGTH, hashmap_element_s::in_use, hashmap_s::keyarray, hashmap_s::size, and hashmap_s::table_size.
Referenced by addLevel().
◆ hashmap_iterate_pairs()
|
static |
Iterate over all the elements in a hashmap.
- Parameters
-
hashmap The hashmap to iterate over. hashmap_new The new hashmap.
- Returns
- If the entire hashmap was iterated then 0 is returned.
Definition at line 341 of file dpborder_hashmap.h.
References hashmap_s::elements, hashmap_rehash_iterator(), hashmap_element_s::in_use, r, hashmap_s::size, and hashmap_s::table_size.
Referenced by hashmap_rehash_helper().
◆ hashmap_num_entries()
|
static |
Get the size of the hashmap.
- Parameters
-
hashmap The hashmap to get the size of.
- Returns
- The size of the hashmap.
Definition at line 372 of file dpborder_hashmap.h.
References hashmap_s::size.
◆ hashmap_isEmpty()
Definition at line 377 of file dpborder_hashmap.h.
References hashmap_s::size.
Referenced by addLevel().
◆ hashmap_destroy()
|
static |
Destroy the hashmap.
- Parameters
-
hashmap The hashmap to destroy.
Definition at line 367 of file dpborder_hashmap.h.
References hashmap_s::elements.
Referenced by dpborder_free(), and hashmap_rehash_helper().
◆ hashmap_crc32_helper()
|
static |
Definition at line 381 of file dpborder_hashmap.h.
References HASHMAP_CAST.
Referenced by hashmap_hash_helper_int_helper().
◆ hashmap_hash_helper_int_helper()
|
static |
Definition at line 456 of file dpborder_hashmap.h.
References hashmap_crc32_helper(), and hashmap_s::table_size.
Referenced by hashmap_get(), hashmap_hash_helper(), and hashmap_remove().
◆ hashmap_hash_helper()
|
static |
Definition at line 477 of file dpborder_hashmap.h.
References hashmap_s::elements, hashmap_hash_helper_int_helper(), hashmap_match_helper(), HASHMAP_MAX_CHAIN_LENGTH, hashmap_element_s::in_use, hashmap_s::keyarray, hashmap_s::size, and hashmap_s::table_size.
Referenced by hashmap_put(), and hashmap_putcheck().
◆ hashmap_rehash_iterator()
|
static |
Definition at line 526 of file dpborder_hashmap.h.
References hashmap_putcheck(), hashmap_element_s::key_len, hashmap_element_s::key_position, and hashmap_element_s::value.
Referenced by hashmap_iterate_pairs().
◆ hashmap_rehash_helper()
|
static |
Definition at line 540 of file dpborder_hashmap.h.
References hashmap_create(), hashmap_destroy(), hashmap_iterate_pairs(), hashmap_s::keyarray, SCIP_OKAY, and hashmap_s::table_size.
Referenced by hashmap_put(), and hashmap_putcheck().
◆ hashmap_match_helper()
|
inlinestatic |
Definition at line 195 of file dpborder_hashmap.h.
References hashmap_element_s::key_len, and hashmap_element_s::key_position.
Referenced by hashmap_get(), hashmap_hash_helper(), and hashmap_remove().