libcdsb/include/extra/map.h

43 lines
1.6 KiB
C
Raw Normal View History

2022-06-08 09:56:14 +03:00
/* 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)
2022-08-16 01:36:37 +03:00
extern bool libcdsb_map_update (vtype_map* x, const void* key, vtype key_type, const void* value, vtype value_type) Nonnull__(1);
extern int libcdsb_map_find (vtype_map* x, const void* key, vtype key_type, void* data, map_access_callback, bool cut) Nonnull__(1);
extern int libcdsb_map_foreach(vtype_map* x, void* data, map_access_callback, bool flush) Nonnull__(1,3);
2022-06-08 09:56:14 +03:00
#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 */