/* This software is licensed by the MIT License, see LICENSE file */ /* Copyright © 2022 Gregory Lirent */ #include #include #include "../include/array.h" typedef vtype_array arr_t; int print_value(vtype_variable value, ssize_t index, void* data) { const char *n = data; vtype_int32 *v = value.pointer; assert(value.type == VTYPE_INT32); printf("%s %d (index: %ld)\n", n, *v, index); return 0; } int main(int argc, char** argv) { arr_t arr; array_init(&arr, VTYPE_INT32); for (size_t i = 0; i < 28; ++i) { array_push_back(&arr, i); } array_get_by_index(&arr, 13, "Get value:", print_value); array_pop_by_index(&arr, 18, "Pop value:", print_value); array_foreach(&arr, "Foreach loop:", print_value); array_free(&arr); }