2022-06-06 11:23:33 +03:00
|
|
|
/* This software is licensed by the MIT License, see LICENSE file */
|
|
|
|
/* Copyright © 2022 Gregory Lirent */
|
|
|
|
|
2022-08-24 11:43:27 +03:00
|
|
|
#include "bits/__generics.h"
|
|
|
|
#include "bits/__rbtree.h"
|
2022-06-06 11:23:33 +03:00
|
|
|
#include "vtype.h"
|
|
|
|
|
|
|
|
#ifndef LIBCDSB_SET_H
|
|
|
|
#define LIBCDSB_SET_H
|
|
|
|
|
2023-03-23 16:21:52 +03:00
|
|
|
typedef int (*vset_access_callback)(vtype_variable value, void* data);
|
2022-06-08 20:59:46 +03:00
|
|
|
|
2022-08-19 17:19:22 +03:00
|
|
|
/*#####################################################################################################################*/
|
|
|
|
|
2022-08-16 01:36:37 +03:00
|
|
|
extern void vset_init(vtype_set* x, vtype type) Nonnull__(1);
|
2022-06-06 11:23:33 +03:00
|
|
|
|
2022-08-19 17:19:22 +03:00
|
|
|
/*#####################################################################################################################*/
|
2022-08-17 22:20:04 +03:00
|
|
|
|
2023-03-23 16:29:10 +03:00
|
|
|
#define vset_pop(x, value, data, callback) libcdsb_vset_find (x, _LIBCDSB_var(value), data, callback, 1)
|
|
|
|
#define vset_get(x, value, data, callback) libcdsb_vset_find (x, _LIBCDSB_var(value), data, callback, 0)
|
|
|
|
#define vset_push(x, value) libcdsb_vset_insert (x, _LIBCDSB_var(value))
|
|
|
|
#define vset_attach(x, value) libcdsb_vset_attach (x, _LIBCDSB_var(value))
|
2022-08-24 11:43:27 +03:00
|
|
|
#define vset_foreach(x, data, callback) libcdsb_vset_foreach(x, data, callback, RBFOREACH_UNSPECIFIED, 0)
|
2022-08-19 17:19:22 +03:00
|
|
|
#define vset_remove(x, value) vset_pop (x, value, 0, 0)
|
2022-06-06 11:23:33 +03:00
|
|
|
|
2022-08-19 17:19:22 +03:00
|
|
|
#define in_vset(x, value) (vset_get(x, value, 0, 0) == 0)
|
2022-06-06 11:23:33 +03:00
|
|
|
|
2022-08-19 17:19:22 +03:00
|
|
|
/*#####################################################################################################################*/
|
2022-08-16 01:36:37 +03:00
|
|
|
|
2023-03-23 16:21:52 +03:00
|
|
|
extern bool libcdsb_vset_insert (vtype_set* x, vtype_variable) Nonnull__(1);
|
|
|
|
extern bool libcdsb_vset_attach (vtype_set* x, vtype_variable) Nonnull__(1);
|
|
|
|
extern int libcdsb_vset_find (vtype_set* x, vtype_variable, void* data, vset_access_callback, bool cut) Nonnull__(1);
|
|
|
|
extern int libcdsb_vset_foreach(vtype_set* x, void* data, vset_access_callback, rbforeach_t, bool flush) Nonnull__(1,3);
|
2022-06-06 11:23:33 +03:00
|
|
|
|
|
|
|
#endif /* LIBCDSB_SET_H */
|