Files
cKit/Foundation/c_ArrayList.h
T
2026-08-30 01:48:03 +08:00

49 lines
1.3 KiB
C

#ifndef INCLUDED_C_ARRAYLIST_H
#define INCLUDED_C_ARRAYLIST_H
#ifndef INCLUDED_C_TYPES_H
#include <c_Types.h>
#endif /*INCLUDED_C_TYPES_H*/
#ifndef INCLUDED_C_ALLOCATOR_H
#include <c_Allocator.h>
#endif /*INCLUDED_C_ALLOCATOR_H*/
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
typedef struct {
void* array;
c_size_t item_size;
c_size_t capacity;
c_size_t size;
c_Allocator_t allocator;
}c_ArrayList_t;
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
c_err_t c_ArrayList_Init(c_ArrayList_t *self, c_size_t item_size, c_size_t capacity, c_Allocator_t *allocator);
void c_ArrayList_Destroy(c_ArrayList_t* self);
c_err_t c_ArrayList_Resize(c_ArrayList_t* self, c_size_t new_capacity);
c_err_t c_ArrayList_Add(c_ArrayList_t* self, const void* item);
void* c_ArrayList_Get(const c_ArrayList_t* self, c_size_t index);
c_err_t c_ArrayList_Read(const c_ArrayList_t* self, c_size_t index, void* out_item);
c_err_t c_ArrayList_Remove(c_ArrayList_t* self, c_size_t index, void* out_item);
C_STATIC_FORCE_INLINE
c_size_t c_ArrayList_Size(const c_ArrayList_t* self) {
if (!self) return 0;
return self->size;
}
#endif /*INCLUDED_C_ARRAYLIST_H*/