List access standardization
This commit is contained in:
+6
-10
@@ -6,22 +6,18 @@
|
||||
#ifndef LIBCDSB_EXTRA_LIST_H
|
||||
#define LIBCDSB_EXTRA_LIST_H
|
||||
|
||||
typedef int (*list_foreach_callback)(void* value, ssize_t index, vtype type, void* data);
|
||||
|
||||
|
||||
#define list_get_by_index(x, s, index) libcdsb_list_get(x, s, index, 0)
|
||||
#define list_pop_by_index(x, s, index) libcdsb_list_get(x, s, index, 1)
|
||||
#define list_remove_by_index(s, index) libcdsb_list_get(0, s, index, 1)
|
||||
#define list_get_by_index(x, index, data, callback) libcdsb_list_get(x, index, data, callback, 0)
|
||||
#define list_pop_by_index(x, index, data, callback) libcdsb_list_get(x, index, data, callback, 1)
|
||||
#define list_remove_by_index(x, index) libcdsb_list_get(x, index, 0, 0, 1)
|
||||
|
||||
#define list_foreach(x, data, callback) libcdsb_list_foreach(x, data, callback, 0)
|
||||
|
||||
extern ssize_t libcdsb_list_find (vtype_value* x, vtype_list* s, const void* value, vtype type, _Bool reverse, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn2__;
|
||||
extern _Bool libcdsb_list_update(vtype_list* x, ssize_t index, const void* value, vtype type, int ins_direction) LIBCDSB_nt__ LIBCDSB_nn1__;
|
||||
|
||||
extern size_t libcdsb_list_count(const vtype_list* s, const void* value, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__;
|
||||
|
||||
extern ssize_t libcdsb_list_get(vtype_value* x, vtype_list* s, ssize_t index, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn2__;
|
||||
|
||||
extern int libcdsb_list_foreach(vtype_list* x, void* data, list_foreach_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
|
||||
extern int libcdsb_list_find (vtype_list* x, const void* value, vtype type, void* data, list_access_callback, _Bool reverse, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
|
||||
extern int libcdsb_list_get (vtype_list* x, ssize_t index, void* data, list_access_callback, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
|
||||
extern int libcdsb_list_foreach(vtype_list* x, void* data, list_access_callback, _Bool flush) LIBCDSB_nt__ LIBCDSB_nn13__;
|
||||
|
||||
#endif /* LIBCDSB_EXTRA_LIST_H */
|
||||
|
||||
+27
-26
@@ -9,19 +9,20 @@
|
||||
|
||||
/*#####################################################################################################################*/
|
||||
|
||||
typedef int (*list_access_callback)(void* value, ssize_t index, vtype type, void* data);
|
||||
|
||||
extern void list_init(vtype_list* x);
|
||||
extern void list_extend(vtype_list* x, const vtype_list* s);
|
||||
|
||||
extern void list_sort(vtype_list* x);
|
||||
extern void list_reverse(vtype_list* x);
|
||||
|
||||
#define list_pop(x, s, value) _LIBCDSB_Generic(libcdsb_list, find, value)(x, s, value, 0, 1)
|
||||
#define list_find(x, s, value) _LIBCDSB_Generic(libcdsb_list, find, value)(x, s, value, 0, 0)
|
||||
#define list_rfind(x, s, value) _LIBCDSB_Generic(libcdsb_list, find, value)(x, s, value, 1, 0)
|
||||
#define list_countof(s, value) _LIBCDSB_Generic(libcdsb_list, count, value)(s, value)
|
||||
#define list_indexof(s, value) list_find(0, s, value)
|
||||
#define list_remove(s, value) list_pop(0, s, value)
|
||||
#define in_list(s, value) (list_indexof(s, value) >= 0)
|
||||
#define list_pop(x, value, data, callback) _LIBCDSB_Generic(libcdsb_list, find, value)(x, value, data, callback, 0, 1)
|
||||
#define list_find(x, value, data, callback) _LIBCDSB_Generic(libcdsb_list, find, value)(x, value, data, callback, 0, 0)
|
||||
#define list_rfind(x, value, data, callback) _LIBCDSB_Generic(libcdsb_list, find, value)(x, value, data, callback, 1, 0)
|
||||
#define list_countof(x, value) _LIBCDSB_Generic(libcdsb_list, count, value)(x, value)
|
||||
#define list_remove(x, value) list_pop(x, value, 0, 0)
|
||||
#define in_list(x, value) (list_find(x, value, 0, 0) == 0)
|
||||
|
||||
#define list_insert(x, index, value) _LIBCDSB_Generic(libcdsb_list, update, value)(x, index, value, -1)
|
||||
#define list_replace(x, index, value) _LIBCDSB_Generic(libcdsb_list, update, value)(x, index, value, 0)
|
||||
@@ -30,25 +31,25 @@ extern void list_reverse(vtype_list* x);
|
||||
|
||||
/*#####################################################################################################################*/
|
||||
|
||||
extern ssize_t libcdsb_list_find_pointer(vtype_value* x, vtype_list* s, const void* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_cstring(vtype_value* x, vtype_list* s, const char* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_string (vtype_value* x, vtype_list* s, const vtype_string* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_array (vtype_value* x, vtype_list* s, const vtype_array* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_list (vtype_value* x, vtype_list* s, const vtype_list* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_map (vtype_value* x, vtype_list* s, const vtype_map* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_vset (vtype_value* x, vtype_list* s, const vtype_set* value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_boolean(vtype_value* x, vtype_list* s, vtype_bool value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_int8 (vtype_value* x, vtype_list* s, vtype_int8 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_int16 (vtype_value* x, vtype_list* s, vtype_int16 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_int32 (vtype_value* x, vtype_list* s, vtype_int32 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_int64 (vtype_value* x, vtype_list* s, vtype_int64 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_uint8 (vtype_value* x, vtype_list* s, vtype_uint8 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_uint16 (vtype_value* x, vtype_list* s, vtype_uint16 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_uint32 (vtype_value* x, vtype_list* s, vtype_uint32 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_uint64 (vtype_value* x, vtype_list* s, vtype_uint64 value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_float (vtype_value* x, vtype_list* s, vtype_float value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_double (vtype_value* x, vtype_list* s, vtype_double value, _Bool reverse, _Bool cut);
|
||||
extern ssize_t libcdsb_list_find_ldouble(vtype_value* x, vtype_list* s, vtype_ldouble value, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_pointer(vtype_list* x, const void* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_cstring(vtype_list* x, const char* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_string (vtype_list* x, const vtype_string* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_array (vtype_list* x, const vtype_array* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_list (vtype_list* x, const vtype_list* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_map (vtype_list* x, const vtype_map* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_vset (vtype_list* x, const vtype_set* value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_boolean(vtype_list* x, vtype_bool value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_int8 (vtype_list* x, vtype_int8 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_int16 (vtype_list* x, vtype_int16 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_int32 (vtype_list* x, vtype_int32 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_int64 (vtype_list* x, vtype_int64 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_uint8 (vtype_list* x, vtype_uint8 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_uint16 (vtype_list* x, vtype_uint16 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_uint32 (vtype_list* x, vtype_uint32 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_uint64 (vtype_list* x, vtype_uint64 value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_float (vtype_list* x, vtype_float value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_double (vtype_list* x, vtype_double value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
extern int libcdsb_list_find_ldouble(vtype_list* x, vtype_ldouble value, void* data, list_access_callback, _Bool reverse, _Bool cut);
|
||||
|
||||
extern size_t libcdsb_list_count_pointer(const vtype_list* s, const void* value);
|
||||
extern size_t libcdsb_list_count_cstring(const vtype_list* s, const char* value);
|
||||
|
||||
Reference in New Issue
Block a user