/* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ #include "vtype.h" #ifndef LIBCDSB_SET_H #define LIBCDSB_SET_H typedef int (*vset_access_callback)(const void* value, vtype type, void* data); /*#####################################################################################################################*/ extern void vset_init(vtype_set* x, vtype type) Nonnull__(1); /*#####################################################################################################################*/ #define vset_pop(x, value, data, callback) libcdsb_vset_find (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), data, callback, 1) #define vset_get(x, value, data, callback) libcdsb_vset_find (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), data, callback, 0) #define vset_push(x, value) libcdsb_vset_insert (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)) #define vset_attach(x, value) libcdsb_vset_attach (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)) #define vset_foreach(x, data, callback) libcdsb_vset_foreach(x, data, callback, 0) #define vset_remove(x, value) vset_pop (x, value, 0, 0) #define in_vset(x, value) (vset_get(x, value, 0, 0) == 0) /*#####################################################################################################################*/ extern bool libcdsb_vset_insert (vtype_set* x, const void* value, vtype type) Nonnull__(1); extern bool libcdsb_vset_attach (vtype_set* x, const void* value, vtype type) Nonnull__(1); extern int libcdsb_vset_find (vtype_set* x, const void* value, vtype type, void* data, vset_access_callback, bool cut) Nonnull__(1); extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, bool flush) Nonnull__(1,3); #endif /* LIBCDSB_SET_H */