libcproject
C static library easier to use than libc (C standard library).
array_list.h
Go to the documentation of this file.
1 #ifndef __LIBCPROJECT_ARRAY_LIST__
2 #define __LIBCPROJECT_ARRAY_LIST__
3 
4 #include <errno.h>
5 #include <stdbool.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 #include "types.h"
10 
11 #define ARRAY_LIST_INITIAL_CAPACITY 10
12 
17 struct array_list {
18  void** data;
19  size_t size;
20  size_t capacity;
21  size_t capacity_step;
22 };
23 
29 
35 
43 void array_list_add(struct array_list* list, void* element);
44 
52 void array_list_remove(struct array_list* list, size_t index);
53 
62 void* array_list_get(struct array_list* list, size_t index);
63 
70 void array_list_free(struct array_list* list);
71 
72 #endif
size_t capacity_step
Definition: array_list.h:21
size_t size
Definition: array_list.h:19
struct array_list * array_list_initialization_with_capacity(size_t capacity)
Initializes a new array list with a capacity.
void array_list_add(struct array_list *list, void *element)
Adds an element to the end of the array list.
struct array_list * array_list_initialization()
Initializes a new array list.
void * array_list_get(struct array_list *list, size_t index)
Gets an element from the array list.
void array_list_free(struct array_list *list)
Frees the array list.
void ** data
Definition: array_list.h:18
void array_list_remove(struct array_list *list, size_t index)
Removes an element from the array list.
size_t capacity
Definition: array_list.h:20
A dynamic array implementation.
Definition: array_list.h:17