47 lines
1.7 KiB
C
47 lines
1.7 KiB
C
|
/* This software is licensed by the MIT License, see LICENSE file */
|
||
|
/* Copyright © 2022 Gregory Lirent */
|
||
|
|
||
|
#include "../map.h"
|
||
|
|
||
|
#ifndef LIBCDSB_EXTRA_MAP_H
|
||
|
#define LIBCDSB_EXTRA_MAP_H
|
||
|
|
||
|
typedef int (*map_foreach_callback)(const void* key, vtype key_type, void* value, vtype value_type, void* data);
|
||
|
|
||
|
|
||
|
#define map_foreach(x, data, callback) libcdsb_map_foreach(x, data, callback, 0)
|
||
|
|
||
|
extern _Bool libcdsb_map_find(vtype_value* x, vtype_map* s, const void* key, vtype key_type, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn23__;
|
||
|
extern _Bool libcdsb_vset_update(vtype_map* x, const void* k, vtype kt, const void* v, vtype vt) LIBCDSB_nt__ LIBCDSB_nn124__;
|
||
|
|
||
|
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
|
||
|
|
||
|
#endif /* LIBCDSB_EXTRA_MAP_H */
|
||
|
|
||
|
|
||
|
#if defined(LIBCDSB_SET_H) && !defined(LIBCDSB_EXTRA_MAP_H_EXT)
|
||
|
#define LIBCDSB_EXTRA_MAP_H_EXT
|
||
|
|
||
|
#define map_copy_keys(s) _Generic((s),\
|
||
|
const vtype_map*: vset_copy, vtype_map*: vset_copy,\
|
||
|
const void*: vset_copy, void*: vset_copy\
|
||
|
)((set_t*)(s))
|
||
|
|
||
|
#define map_duplicate_keys(s) _Generic((s),\
|
||
|
const vtype_map*: vset_duplicate, vtype_map*: vset_duplicate,\
|
||
|
const void*: vset_duplicate, void*: vset_duplicate\
|
||
|
)((set_t*)(s))
|
||
|
|
||
|
#define map_copy_init_keys(x, s) _Generic((x),\
|
||
|
vtype_set*: _Generic((s),\
|
||
|
const vtype_map*: vset_copy_init, vtype_map*: vset_copy_init,\
|
||
|
const void*: vset_copy_init, void*: vset_copy_init\
|
||
|
),\
|
||
|
void*: _Generic((s),\
|
||
|
const vtype_map*: vset_copy_init, vtype_map*: vset_copy_init,\
|
||
|
const void*: vset_copy_init, void*: vset_copy_init\
|
||
|
)\
|
||
|
)((x), (set_t*)(s))
|
||
|
|
||
|
#endif /* LIBCDSB_EXTRA_MAP_H_EXT */
|