33 lines
1.2 KiB
C
33 lines
1.2 KiB
C
/*
|
|
* What is this?
|
|
*
|
|
* A list (as I interpret it in this library)
|
|
* is a `vector_t` of other `vector_t`s, where
|
|
* every inner `vector_t` can be of any type ->
|
|
* this means a Python-like list
|
|
*/
|
|
|
|
#include <odweta/vector.h>
|
|
#include <odweta/util.h>
|
|
|
|
typedef struct {
|
|
size_t size; // number of elements that are inside the list
|
|
size_t capacity; // how many elements can be put inside
|
|
vector_t* data; // vector of vectors
|
|
} list_t;
|
|
|
|
list_t* listInit(); // returns a new list
|
|
|
|
void listPush(list_t* l, dataType_e type, void* element); // appends an element at the end of a list
|
|
|
|
void listPrint(list_t* l); // prints a list
|
|
void _listPrintRecursive(list_t* l, int depth);
|
|
|
|
void listCleanup(list_t* l); // freeing pointers
|
|
|
|
void* listPop(list_t* l); // popping the last value of the list and returning it
|
|
|
|
void listInsertAt(list_t* l, int index, dataType_e type, void* element); // inserts an element at a given index
|
|
|
|
void listRemoveAt(list_t* l, int index);
|