libcdsb/include/extra/map.h

44 lines
1.6 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
#define map_foreach(x, data, callback) libcdsb_map_foreach(x, data, callback, 0)
extern _Bool libcdsb_map_update(vtype_map* x, const void* k, vtype kt, const void* v, vtype vt) LIBCDSB_nt__ LIBCDSB_nn124__;
extern int libcdsb_map_find (vtype_map* x, const void* key, vtype key_type, void* data, map_access_callback, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_access_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 */