![]() |
librnr
1.14.5
RoadNarrows Robotics Common Library 1
|
Example of using a librnr hash table. More...
#include <stdio.h>#include <string.h>#include <ctype.h>#include <stdarg.h>#include "rnr/rnrconfig.h"#include "rnr/new.h"#include "rnr/log.h"#include "rnr/hash.h"Go to the source code of this file.
Typedefs | |
| typedef char | input_t[256] |
| Working input buffer. | |
Functions | |
| static int | tokenize (char *string,...) |
| Tokenize input. More... | |
| static void | del_node_data (void *key, void *val) |
| Delete node data - both key and value are dynamically allocated. More... | |
| static void | force_grow (hash_t *h) |
| Force table to grow by feeding the table random entries. More... | |
| static void | force_shrink (hash_t *h) |
| Force table to shink by deleting table random entries. More... | |
| int | main (int argc, char *argv[]) |
| Example main. More... | |
Variables | |
| static char * | Colorado14ers [][2] |
| Colorado's 14,000+ foot mountains. More... | |
| static int | MtnCounter = 0 |
| Make random keys unique. | |
Example of using a librnr hash table.
Definition in file example_hash.c.
|
static |
Delete node data - both key and value are dynamically allocated.
| key | Data key. |
| val | Data value. |
Definition at line 110 of file example_hash.c.
Referenced by force_grow(), and main().
|
static |
Force table to grow by feeding the table random entries.
| h | Pointer to hash table. |
Definition at line 151 of file example_hash.c.
References arraysize, Colorado14ers, del_node_data(), hash_count, hash_insert(), hash_size, hash_t::highmark, MtnCounter, and new_strdup().
Referenced by main().
|
static |
Force table to shink by deleting table random entries.
| h | Pointer to hash table. |
Definition at line 197 of file example_hash.c.
References hash_count, hash_node_delete(), hash_scan_begin(), hash_scan_next(), hash_size, hnode_get, hnode_getkey, hash_t::lowmark, and NULL.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Example main.
| argc | Command-line argument count. |
| argv | Command-line argument list. |
Definition at line 238 of file example_hash.c.
References del_node_data(), force_grow(), force_shrink(), hash_count, hash_insert(), hash_lookup(), hash_node_delete(), hash_scan_begin(), hash_scan_next(), hash_set_self_verify(), hash_size, hash_table_create(), hash_table_destroy(), HASHCOUNT_T_MAX, hnode_get, hnode_getkey, LOG_SET_THRESHOLD(), new_strdup(), NULL, and tokenize().
|
static |
Tokenize input.
| string | Input string to parse. | |
| [out] | ... | Variable argument list of char** arguments terminated by a last NULL argument. |
Definition at line 68 of file example_hash.c.
Referenced by main().
|
static |
Colorado's 14,000+ foot mountains.
N.B. there are 53 of them, I'm stopping at the highest 16.
Definition at line 121 of file example_hash.c.
Referenced by force_grow().