重构
This commit is contained in:
@@ -5,32 +5,44 @@
|
||||
#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;
|
||||
int obj_size;
|
||||
c_size_t item_size;
|
||||
c_size_t capacity;
|
||||
c_size_t size;
|
||||
c_Allocator_t allocator;
|
||||
}c_ArrayList_t;
|
||||
|
||||
#define c_ArrayList(obj_size) ((c_ArrayList_t) { 0, (obj_size), 0, 0 })
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------------------------ */
|
||||
/* */
|
||||
|
||||
c_err_t c_ArrayList_Init(c_ArrayList_t* self, c_size_t obj_size, c_size_t capacity);
|
||||
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_Add(c_ArrayList_t* self, void* obj);
|
||||
c_err_t c_ArrayList_Resize(c_ArrayList_t* self, c_size_t new_capacity);
|
||||
|
||||
void* c_ArrayList_Get(c_ArrayList_t* self, c_size_t index);
|
||||
c_err_t c_ArrayList_Add(c_ArrayList_t* self, const void* item);
|
||||
|
||||
c_err_t c_ArrayList_Remove(c_ArrayList_t* self, c_size_t index);
|
||||
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*/
|
||||
|
||||
Reference in New Issue
Block a user