Update array
This commit is contained in:
parent
ee6f3d3715
commit
6aca959de7
@ -18,14 +18,13 @@ extern void array_reverse(vtype_array* x) LIBCDSB_nt__ LIBCDSB_nn1__;
|
||||
|
||||
#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 array_remove_by_index(s, index) array_pop_by_index(s, 0, 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__;
|
||||
|
@ -25,27 +25,15 @@ ssize_t array_find(const arr_t* x, const void* v, vtype vt) {
|
||||
|
||||
assert(!is_null(x->mem));
|
||||
|
||||
if (x->type != vt) {
|
||||
do {
|
||||
++index;
|
||||
c = vtype_compare(p, x->type, v, vt);
|
||||
do {
|
||||
++index;
|
||||
c = vtype_compare(p, x->type, v, vt);
|
||||
|
||||
if (c == 0)
|
||||
return index;
|
||||
if (c == 0)
|
||||
return index;
|
||||
|
||||
p += vtype_size(x->type);
|
||||
} while (p < e);
|
||||
} else {
|
||||
do {
|
||||
++index;
|
||||
c = vtype_compare_eq(p, v, vt);
|
||||
|
||||
if (c == 0)
|
||||
return index;
|
||||
|
||||
p += vtype_size(x->type);
|
||||
} while (p < e);
|
||||
}
|
||||
p += vtype_size(x->type);
|
||||
} while (p < e);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user