Add list headers
This commit is contained in:
		
							parent
							
								
									a7aacd9160
								
							
						
					
					
						commit
						5eeb9677d5
					
				
							
								
								
									
										21
									
								
								include/extra/list.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								include/extra/list.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
			
		||||
/* This software is licensed by the MIT License, see LICENSE file */
 | 
			
		||||
/*                                Copyright © 2022 Gregory Lirent */
 | 
			
		||||
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include "../list.h"
 | 
			
		||||
 | 
			
		||||
#ifndef LIBCDSB_EXTRA_LIST_H
 | 
			
		||||
#define LIBCDSB_EXTRA_LIST_H
 | 
			
		||||
 | 
			
		||||
#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)
 | 
			
		||||
 | 
			
		||||
extern ssize_t libcdsb_list_find  (vtype_value* x, vtype_list* s, const void* value, vtype type, _Bool reverse, _Bool cut);
 | 
			
		||||
extern _Bool   libcdsb_list_update(vtype_list*  x, ssize_t index, const void* value, vtype type, int ins_direction);
 | 
			
		||||
 | 
			
		||||
extern size_t  libcdsb_list_count(const vtype_list* s, const void* value, vtype type);
 | 
			
		||||
 | 
			
		||||
extern ssize_t libcdsb_list_get(vtype_value* x, vtype_list* s, ssize_t index, _Bool cut);
 | 
			
		||||
 | 
			
		||||
#endif /* LIBCDSB_EXTRA_LIST_H */
 | 
			
		||||
							
								
								
									
										93
									
								
								include/list.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								include/list.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,93 @@
 | 
			
		||||
/* This software is licensed by the MIT License, see LICENSE file */
 | 
			
		||||
/*                                Copyright © 2022 Gregory Lirent */
 | 
			
		||||
 | 
			
		||||
#include "__generics.h"
 | 
			
		||||
#include "vtype.h"
 | 
			
		||||
 | 
			
		||||
#ifndef LIBCDSB_LIST_H
 | 
			
		||||
#define LIBCDSB_LIST_H
 | 
			
		||||
 | 
			
		||||
/*#####################################################################################################################*/
 | 
			
		||||
 | 
			
		||||
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)(x, 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_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)
 | 
			
		||||
#define list_push_back(x, value)      _LIBCDSB_Generic(libcdsb_list, update, value)(x, -1, value, 1)
 | 
			
		||||
#define list_push_front(x, value)     _LIBCDSB_Generic(libcdsb_list, update, value)(x,  0, value, -1)
 | 
			
		||||
 | 
			
		||||
/*#####################################################################################################################*/
 | 
			
		||||
 | 
			
		||||
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 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);
 | 
			
		||||
extern size_t libcdsb_list_count_string (const vtype_list* s, const vtype_string* value);
 | 
			
		||||
extern size_t libcdsb_list_count_array  (const vtype_list* s, const  vtype_array* value);
 | 
			
		||||
extern size_t libcdsb_list_count_list   (const vtype_list* s, const   vtype_list* value);
 | 
			
		||||
extern size_t libcdsb_list_count_map    (const vtype_list* s, const    vtype_map* value);
 | 
			
		||||
extern size_t libcdsb_list_count_vset   (const vtype_list* s, const    vtype_set* value);
 | 
			
		||||
extern size_t libcdsb_list_count_boolean(const vtype_list* s,          vtype_bool value);
 | 
			
		||||
extern size_t libcdsb_list_count_int8   (const vtype_list* s,          vtype_int8 value);
 | 
			
		||||
extern size_t libcdsb_list_count_int16  (const vtype_list* s,         vtype_int16 value);
 | 
			
		||||
extern size_t libcdsb_list_count_int32  (const vtype_list* s,         vtype_int32 value);
 | 
			
		||||
extern size_t libcdsb_list_count_int64  (const vtype_list* s,         vtype_int64 value);
 | 
			
		||||
extern size_t libcdsb_list_count_uint8  (const vtype_list* s,         vtype_uint8 value);
 | 
			
		||||
extern size_t libcdsb_list_count_uint16 (const vtype_list* s,        vtype_uint16 value);
 | 
			
		||||
extern size_t libcdsb_list_count_uint32 (const vtype_list* s,        vtype_uint32 value);
 | 
			
		||||
extern size_t libcdsb_list_count_uint64 (const vtype_list* s,        vtype_uint64 value);
 | 
			
		||||
extern size_t libcdsb_list_count_float  (const vtype_list* s,         vtype_float value);
 | 
			
		||||
extern size_t libcdsb_list_count_double (const vtype_list* s,        vtype_double value);
 | 
			
		||||
extern size_t libcdsb_list_count_ldouble(const vtype_list* s,       vtype_ldouble value);
 | 
			
		||||
 | 
			
		||||
extern _Bool libcdsb_list_update_pointer(vtype_list* x, ssize_t index, const         void* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_cstring(vtype_list* x, ssize_t index, const         char* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_string (vtype_list* x, ssize_t index, const vtype_string* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_array  (vtype_list* x, ssize_t index, const  vtype_array* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_list   (vtype_list* x, ssize_t index, const   vtype_list* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_map    (vtype_list* x, ssize_t index, const    vtype_map* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_vset   (vtype_list* x, ssize_t index, const    vtype_set* value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_boolean(vtype_list* x, ssize_t index,          vtype_bool value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_int8   (vtype_list* x, ssize_t index,          vtype_int8 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_int16  (vtype_list* x, ssize_t index,         vtype_int16 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_int32  (vtype_list* x, ssize_t index,         vtype_int32 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_int64  (vtype_list* x, ssize_t index,         vtype_int64 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_uint8  (vtype_list* x, ssize_t index,         vtype_uint8 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_uint16 (vtype_list* x, ssize_t index,        vtype_uint16 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_uint32 (vtype_list* x, ssize_t index,        vtype_uint32 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_uint64 (vtype_list* x, ssize_t index,        vtype_uint64 value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_float  (vtype_list* x, ssize_t index,         vtype_float value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_double (vtype_list* x, ssize_t index,        vtype_double value, int ins_direction);
 | 
			
		||||
extern _Bool libcdsb_list_update_ldouble(vtype_list* x, ssize_t index,       vtype_ldouble value, int ins_direction);
 | 
			
		||||
 | 
			
		||||
#endif /* LIBCDSB_LIST_H */
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user