2026-08-29 01:50:50 +08:00
|
|
|
#ifndef INCLUDED_C_ARRAYLIST_H
|
|
|
|
|
#define INCLUDED_C_ARRAYLIST_H
|
|
|
|
|
|
|
|
|
|
#ifndef INCLUDED_C_TYPES_H
|
|
|
|
|
#include <c_Types.h>
|
|
|
|
|
#endif /*INCLUDED_C_TYPES_H*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
void* array;
|
|
|
|
|
int obj_size;
|
|
|
|
|
c_size_t capacity;
|
|
|
|
|
c_size_t size;
|
|
|
|
|
}c_ArrayList_t;
|
|
|
|
|
|
2026-08-29 11:39:28 +08:00
|
|
|
#define c_ArrayList(obj_size) ((c_ArrayList_t) { 0, (obj_size), 0, 0 })
|
|
|
|
|
|
2026-08-29 01:50:50 +08:00
|
|
|
/* ------------------------------------------------------------------------------------------------------------------ */
|
|
|
|
|
/* */
|
|
|
|
|
|
|
|
|
|
c_err_t c_ArrayList_Init(c_ArrayList_t* self, c_size_t obj_size, c_size_t capacity);
|
|
|
|
|
|
|
|
|
|
void c_ArrayList_Destroy(c_ArrayList_t* self);
|
|
|
|
|
|
|
|
|
|
c_err_t c_ArrayList_Add(c_ArrayList_t* self, void* obj);
|
|
|
|
|
|
|
|
|
|
void* c_ArrayList_Get(c_ArrayList_t* self, c_size_t index);
|
|
|
|
|
|
|
|
|
|
c_err_t c_ArrayList_Remove(c_ArrayList_t* self, c_size_t index);
|
|
|
|
|
|
2026-08-29 11:39:28 +08:00
|
|
|
|
2026-08-29 01:50:50 +08:00
|
|
|
#endif /*INCLUDED_C_ARRAYLIST_H*/
|