Update list (vtype_variable)

This commit is contained in:
2023-03-23 13:53:46 +03:00
parent b21ce2e799
commit 6fc4be2b75
3 changed files with 28 additions and 29 deletions
+17 -17
View File
@@ -7,7 +7,7 @@
#ifndef LIBCDSB_LIST_H
#define LIBCDSB_LIST_H
typedef int (*list_access_callback)(void* value, ssize_t index, vtype type, void* data);
typedef int (*list_access_callback)(vtype_variable, ssize_t index, void* data);
/*#####################################################################################################################*/
@@ -21,19 +21,19 @@ inline void list_init (vtype_list* x) { x->first = x->last = 0; }
/*#####################################################################################################################*/
#define list_pop(x, value, data, callback) libcdsb_list_find (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), data, callback, 0, 1)
#define list_pop(x, value, data, callback) libcdsb_list_find (x, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), data, callback, 0, 1)
#define list_get list_find
#define list_pop_by_index(x, index, data, callback) libcdsb_list_get (x, index, data, callback, 1)
#define list_get_by_index(x, index, data, callback) libcdsb_list_get (x, index, data, callback, 0)
#define list_find(x, value, data, callback) libcdsb_list_find (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), data, callback, 0, 0)
#define list_rfind(x, value, data, callback) libcdsb_list_find (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), data, callback, 1, 0)
#define list_countof(x, value) libcdsb_list_count (x, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value))
#define list_insert(x, index, value) libcdsb_list_insert (x, index, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), -1, 0, 0)
#define list_replace(x, index, value) libcdsb_list_insert (x, index, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), 0, 0, 0)
#define list_push_back(x, value) libcdsb_list_insert (x, -1, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), 1, 0, 0)
#define list_push_front(x, value) libcdsb_list_insert (x, 0, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), -1, 0, 0)
#define list_attach_back(x, value) libcdsb_list_attach (x, -1, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), 1, 0, 0)
#define list_attach_front(x, value) libcdsb_list_attach (x, 0, _LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value), -1, 0, 0)
#define list_find(x, value, data, callback) libcdsb_list_find (x, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), data, callback, 0, 0)
#define list_rfind(x, value, data, callback) libcdsb_list_find (x, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), data, callback, 1, 0)
#define list_countof(x, value) libcdsb_list_count (x, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)))
#define list_insert(x, index, value) libcdsb_list_insert (x, index, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), -1, 0, 0)
#define list_replace(x, index, value) libcdsb_list_insert (x, index, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), 0, 0, 0)
#define list_push_back(x, value) libcdsb_list_insert (x, -1, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), 1, 0, 0)
#define list_push_front(x, value) libcdsb_list_insert (x, 0, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), -1, 0, 0)
#define list_attach_back(x, value) libcdsb_list_attach (x, -1, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), 1, 0, 0)
#define list_attach_front(x, value) libcdsb_list_attach (x, 0, libcdsb_variable_build(_LIBCDSB_value_pointer(value), _LIBCDSB_vtypeof(value)), -1, 0, 0)
#define list_foreach(x, data, callback) libcdsb_list_foreach(x, data, callback, 0)
#define list_remove(x, value) list_pop (x, value, 0, 0)
#define list_remove_by_index(x, index) list_pop_by_index (x, index, 0, 0)
@@ -42,12 +42,12 @@ inline void list_init (vtype_list* x) { x->first = x->last = 0; }
/*#####################################################################################################################*/
extern bool libcdsb_list_insert (vtype_list* x, ssize_t index, const void* value, vtype type, int ins_direction, void* data, list_access_callback) Nonnull__(1);
extern bool libcdsb_list_attach (vtype_list* x, ssize_t index, const void* value, vtype type, int ins_direction, void* data, list_access_callback) Nonnull__(1);
extern int libcdsb_list_find (vtype_list* x, const void* value, vtype type, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1);
extern int libcdsb_list_get (vtype_list* x, ssize_t index, void* data, list_access_callback, bool cut) Nonnull__(1);
extern int libcdsb_list_foreach (vtype_list* x, void* data, list_access_callback, bool flush) Nonnull__(1,3);
extern bool libcdsb_list_insert (vtype_list* x, ssize_t index, vtype_variable, int ins_direction, void* data, list_access_callback) Nonnull__(1);
extern bool libcdsb_list_attach (vtype_list* x, ssize_t index, vtype_variable, int ins_direction, void* data, list_access_callback) Nonnull__(1);
extern int libcdsb_list_find (vtype_list* x, vtype_variable, void* data, list_access_callback, bool reverse, bool cut) Nonnull__(1);
extern int libcdsb_list_get (vtype_list* x, ssize_t index, void* data, list_access_callback, bool cut) Nonnull__(1);
extern int libcdsb_list_foreach (vtype_list* x, void* data, list_access_callback, bool flush) Nonnull__(1,3);
extern size_t libcdsb_list_count(const vtype_list* s, const void* value, vtype type) Pure__ Warn_unused_result__ Nonnull__(1);
extern size_t libcdsb_list_count(const vtype_list* s, vtype_variable) Pure__ Warn_unused_result__ Nonnull__(1);
#endif /* LIBCDSB_LIST_H */