#include "darr.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
Go to the source code of this file.
Functions | |
bool | _increase_darr (darr_t *da) |
private method form darr_t | |
bool | _shrink_darr (darr_t *da) |
private method form darr_t | |
darr_t * | darr_new (void) |
size_t | darr_get_size (darr_t *da) |
size_t | darr_get_capacity (darr_t *da) |
void * | darr_at (darr_t *da, size_t index) |
int | darr_push (darr_t *da, void *value, size_t size) |
int | darr_pop (darr_t *da) |
int | darr_insert_at (darr_t *da, size_t index, void *value, size_t size) |
int | darr_delete_at (darr_t *da, size_t index) |
int | darr_find (darr_t *da, void *value, compfun_t compare) |
void | darr_destroy (darr_t *da) |
bool _increase_darr | ( | darr_t * | da | ) |
private method form darr_t
Definition at line 145 of file darr.c.
bool _shrink_darr | ( | darr_t * | da | ) |
void * darr_at | ( | darr_t * | da, |
size_t | index ) |
int darr_delete_at | ( | darr_t * | da, |
size_t | index ) |
void darr_destroy | ( | darr_t * | da | ) |
size_t darr_get_capacity | ( | darr_t * | da | ) |
Simple getter, this one was intended to be used for debugging propurses, but it can be in handy when needing to have fine control over the memory usage.
darr_t._capacity
attribute. Definition at line 45 of file darr.c.
size_t darr_get_size | ( | darr_t * | da | ) |
Simple getter, intended to be used in for
/while
loops to interact with the array itself.
darr_t._size
attribute. Definition at line 37 of file darr.c.
int darr_insert_at | ( | darr_t * | da, |
size_t | index, | ||
void * | value, | ||
size_t | size ) |
darr_t * darr_new | ( | void | ) |
Creates a darr_t
instance in the heap and allocates the initial size that the array will occupe based on the DARR_DEFAULT_CAPACITY
value. The array will be a pointer [array] to other pointers with void
(generic) type, this means that the items should be castet to some type when using, e.g.: *(float *)da->_arr[1]
or, even better, *(float *)darr_at(da, 1)
.
darr_t
instance, it should be used in the other darr_*()
methods to interact with the array itself. int darr_pop | ( | darr_t * | da | ) |
int darr_push | ( | darr_t * | da, |
void * | value, | ||
size_t | size ) |