1// This file is part of SmallBASIC
2//
3// Support for dictionary/associative array variables
4//
5// This program is distributed under the terms of the GPL v2.0 or later
6// Download the GNU Public License (GPL) from www.gnu.org
7//
8// Copyright(C) 2007-2019 Chris Warren-Smith.
9
10#ifndef _HASHMAP_H_
11#define _HASHMAP_H_
12
13#include "common/var.h"
14
15/**
16 * Callback structure for hashmap_foreach
17 */
18typedef struct hashmap_cb {
19 var_p_t var;
20 var_p_t parent;
21 char *buffer;
22 int count;
23 int index;
24 int start;
25} hashmap_cb;
26
27typedef int (*hashmap_foreach_func)(hashmap_cb *cb, var_p_t k, var_p_t v);
28
29void hashmap_create(var_p_t map, int size);
30int hashmap_destroy(var_p_t map);
31var_p_t hashmap_put(var_p_t map, const char *key, int length);
32var_p_t hashmap_putc(var_p_t map, const char *key, int length);
33var_p_t hashmap_putv(var_p_t map, const var_p_t key);
34var_p_t hashmap_get(var_p_t map, const char *key);
35void hashmap_foreach(var_p_t map, hashmap_foreach_func func, hashmap_cb *data);
36
37#endif /* !_HASHMAP_H_ */
38
39