1#pragma once
2
3/*
4 * Map internals.
5 */
6
7#include "include/pw_types.h"
8#include "src/types/hash_table.h"
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14// capacity must be power of two, it doubles when map needs to grow
15#define PWMAP_INITIAL_CAPACITY 8
16
17PW_STRUCT(_PwMap) {
18 _PwArray kv_pairs; // key-value pairs in the insertion order
19 _PwHashTable hash_table;
20};
21
22#define get_map(value) \
23 __extension__ \
24 ({ \
25 _PwMap* __map = _pw_get_struct_ptr((value), PwTypeId_BasicMap); \
26 if (!__map) { \
27 pw_set_status(PwStatus(PweIncompatibleType, "Expected map")); \
28 } \
29 __map; \
30 })
31
32extern PwInterface_Basic _pw_basic_map_basic_interface;
33extern PwInterface_RandomAccess _pw_basic_map_random_access_interface;
34
35#ifdef __cplusplus
36}
37#endif