Download h source code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018,2023 Jeisson Hidalgo <jeisson.hidalgo@ucr.ac.cr> CC-BY 4.0
#ifndef ARRAY_H
#define ARRAY_H

#include <stddef.h>

typedef void** array_t;

static const size_t array_not_found = (size_t)-1;

array_t array_create(size_t capacity);
void array_destroy(array_t array);
int array_append(array_t array, void* element);
size_t array_get_count(const array_t array);
void* array_get_element(array_t array, size_t index);
size_t array_find_first(const array_t array, const void* element,
                        size_t start_pos);
int array_remove_first(array_t array, const void* element, size_t start_pos);

#endif  // ARRAY_H