libcdsb/include/array.h

70 lines
5.6 KiB
C

/* This software is licensed by the MIT License, see LICENSE file */
/* Copyright © 2022 Gregory Lirent */
#include "__generics.h"
#include "vtype.h"
#ifndef LIBCDSB_ARRAY_H
#define LIBCDSB_ARRAY_H
extern void array_init(vtype_array* x, vtype type) LIBCDSB_nt__ LIBCDSB_nn1__;
extern _Bool array_slice(vtype_array* x, vtype_array* src, ssize_t index, size_t count, _Bool cut) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void array_sort (vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__;
#define array_push(x, value) _LIBCDSB_Generic(libcdsb_array, push, value)(x, value)
#define array_indexof(x, value) _LIBCDSB_Generic(libcdsb_array, indexof, value)(x, value)
#define array_get_by_index(s, x, index) array_get(s, x, index, 0)
#define array_pop_by_index(s, x, index) array_get(s, x, index, 1)
#define array_remove_by_index(s, index) array_pop_by_index(s, nullptr, index)
#define in_array(x, value) (array_indexof(x, value) >= 0)
extern void* array_at (const vtype_array* s, ssize_t index);
extern ssize_t array_get(vtype_array* s, vtype_value* x, ssize_t index, _Bool cut);
extern void libcdsb_array_push_pointer(vtype_array* x, const void* value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_cstring(vtype_array* x, const char* value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_string (vtype_array* x, const vtype_string* value) LIBCDSB_nt__ LIBCDSB_nn12__;
extern void libcdsb_array_push_array (vtype_array* x, const vtype_array* value) LIBCDSB_nt__ LIBCDSB_nn12__;
extern void libcdsb_array_push_list (vtype_array* x, const vtype_list* value) LIBCDSB_nt__ LIBCDSB_nn12__;
extern void libcdsb_array_push_map (vtype_array* x, const vtype_map* value) LIBCDSB_nt__ LIBCDSB_nn12__;
extern void libcdsb_array_push_vset (vtype_array* x, const vtype_set* value) LIBCDSB_nt__ LIBCDSB_nn12__;
extern void libcdsb_array_push_boolean(vtype_array* x, vtype_bool value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_uint8 (vtype_array* x, vtype_uint8 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_uint16 (vtype_array* x, vtype_uint16 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_uint32 (vtype_array* x, vtype_uint32 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_uint64 (vtype_array* x, vtype_uint64 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_int8 (vtype_array* x, vtype_int8 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_int16 (vtype_array* x, vtype_int16 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_int32 (vtype_array* x, vtype_int32 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_int64 (vtype_array* x, vtype_int64 value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_float (vtype_array* x, vtype_float value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_double (vtype_array* x, vtype_double value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern void libcdsb_array_push_ldouble(vtype_array* x, vtype_ldouble value) LIBCDSB_nt__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_pointer(const vtype_array* x, const void* value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_string (const vtype_array* x, const char* value) LIBCDSB_pure__ LIBCDSB_nn12__;
extern ssize_t libcdsb_array_indexof_array (const vtype_array* x, const vtype_string* value) LIBCDSB_pure__ LIBCDSB_nn12__;
extern ssize_t libcdsb_array_indexof_list (const vtype_array* x, const vtype_array* value) LIBCDSB_pure__ LIBCDSB_nn12__;
extern ssize_t libcdsb_array_indexof_map (const vtype_array* x, const vtype_list* value) LIBCDSB_pure__ LIBCDSB_nn12__;
extern ssize_t libcdsb_array_indexof_vset (const vtype_array* x, const vtype_map* value) LIBCDSB_pure__ LIBCDSB_nn12__;
extern ssize_t libcdsb_array_indexof_cstring(const vtype_array* x, const vtype_set* value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_boolean(const vtype_array* x, vtype_bool value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_uint8 (const vtype_array* x, vtype_uint8 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_uint16 (const vtype_array* x, vtype_uint16 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_uint32 (const vtype_array* x, vtype_uint32 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_uint64 (const vtype_array* x, vtype_uint64 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_int8 (const vtype_array* x, vtype_int8 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_int16 (const vtype_array* x, vtype_int16 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_int32 (const vtype_array* x, vtype_int32 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_int64 (const vtype_array* x, vtype_int64 value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_float (const vtype_array* x, vtype_float value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_double (const vtype_array* x, vtype_double value) LIBCDSB_pure__ LIBCDSB_nn1__;
extern ssize_t libcdsb_array_indexof_ldouble(const vtype_array* x, vtype_ldouble value) LIBCDSB_pure__ LIBCDSB_nn1__;
#endif /* LIBCDSB_ARRAY_H */