Dinamic Array
 
Loading...
Searching...
No Matches
darr_t Struct Reference

#include <darr.h>

Public Attributes

void ** _arr
 
size_t _size
 
size_t _capacity
 

Detailed Description

Struct that will hold the actual dinamic array and other informations to search, insert and remove elements from within. Since C doesn't support generic types, the array will be stored as an array that points to a sequence of pointers (I know complicated).

Since all the items is a generic pointer (void*) to something, it's due to the developer to cast that item into a type that makes sence, for an example: darr_at(mydarr, 1) will be a void*, cast this void to a int with (int *)darr_at(mydarr, 1) to interprete this as a pointer to an integer, and now access the value that it's pointing to with an extra *, like *(int *)darr_at(mydarr, 1).

Check the detailed darr_t description for more information about it's attributes.

Definition at line 50 of file darr.h.

Member Data Documentation

◆ _arr

void** darr_t::_arr

Pointer to the array body, the elements should be casted when using.

Definition at line 52 of file darr.h.

◆ _capacity

size_t darr_t::_capacity

Max capacity, this should change when it needs to resize.

Definition at line 56 of file darr.h.

◆ _size

size_t darr_t::_size

Total ammount of spaces being used by the array, used in for loops.

Definition at line 54 of file darr.h.


The documentation for this struct was generated from the following file: