osurs
0.0.1
|
Arraylist data structure. More...
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | ArrayList |
Arraylist. More... | |
Functions | |
void | array_list_init (ArrayList *list) |
Initialize an ArrayList structure. More... | |
ArrayList * | array_list_create () |
Create a new ArrayList structure. More... | |
void | array_list_add (ArrayList *list, void *element) |
Add an element to the end of an ArrayList. More... | |
void | array_list_add_at (ArrayList *list, int index, void *element) |
Add an element to an ArrayList at a specific index. More... | |
void * | array_list_get (ArrayList *list, int index) |
Get an element from an ArrayList. More... | |
void | array_list_free (ArrayList *list) |
Free an ArrayList structure. More... | |
Arraylist data structure.
This file defines an ArrayList data structure, which is a dynamic array that can hold a variable number of elements.
void array_list_add | ( | ArrayList * | list, |
void * | element | ||
) |
Add an element to the end of an ArrayList.
This function adds an element to the end of an ArrayList. If the list's current capacity is not large enough to hold the new element, the capacity is increased to accommodate it.
list | The ArrayList to which the element will be added. |
element | The element to be added to the list. |
void array_list_add_at | ( | ArrayList * | list, |
int | index, | ||
void * | element | ||
) |
Add an element to an ArrayList at a specific index.
This function adds an element to an ArrayList at a specific index. If the list's current capacity is not large enough to hold the new element, the capacity is increased to accommodate it. If the index is greater than the current size of the list, the element is added to the end of the list.
list | The ArrayList to which the element will be added. |
index | The index at which the element will be inserted. |
element | The element to be added to the list. |
ArrayList* array_list_create | ( | ) |
void array_list_free | ( | ArrayList * | list | ) |
void* array_list_get | ( | ArrayList * | list, |
int | index | ||
) |
Get an element from an ArrayList.
This function retrieves an element from an ArrayList at a specific index. If the index is out of range (less than 0 or greater than or equal to the list's size), the function returns NULL.
list | The ArrayList from which the element will be retrieved. |
index | The index of the element to be retrieved. |