Files
cKit/Foundation/c_ArrayList.h
T

49 lines
1.3 KiB
C
Raw Normal View History

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*/
2026-08-30 01:48:03 +08:00
#ifndef INCLUDED_C_ALLOCATOR_H
#include <c_Allocator.h>
#endif /*INCLUDED_C_ALLOCATOR_H*/
2026-08-29 01:50:50 +08:00
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
typedef struct {
void* array;
2026-08-30 01:48:03 +08:00
c_size_t item_size;
2026-08-29 01:50:50 +08:00
c_size_t capacity;
c_size_t size;
2026-08-30 01:48:03 +08:00
c_Allocator_t allocator;
2026-08-29 01:50:50 +08:00
}c_ArrayList_t;
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
2026-08-30 01:48:03 +08:00
c_err_t c_ArrayList_Init(c_ArrayList_t *self, c_size_t item_size, c_size_t capacity, c_Allocator_t *allocator);
2026-08-29 01:50:50 +08:00
void c_ArrayList_Destroy(c_ArrayList_t* self);
2026-08-30 01:48:03 +08:00
c_err_t c_ArrayList_Resize(c_ArrayList_t* self, c_size_t new_capacity);
2026-08-29 01:50:50 +08:00
2026-08-30 01:48:03 +08:00
c_err_t c_ArrayList_Add(c_ArrayList_t* self, const void* item);
2026-08-29 01:50:50 +08:00
2026-08-30 01:48:03 +08:00
void* c_ArrayList_Get(const c_ArrayList_t* self, c_size_t index);
2026-08-29 01:50:50 +08:00
2026-08-30 01:48:03 +08:00
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;
}
2026-08-29 11:39:28 +08:00
2026-08-29 01:50:50 +08:00
#endif /*INCLUDED_C_ARRAYLIST_H*/