#ifndef INCLUDED_C_SMARTPTRVECTOR_H #define INCLUDED_C_SMARTPTRVECTOR_H #ifndef INCLUDED_C_SMARTPTR_H #include #endif /*INCLUDED_C_SMARTPTR_H*/ #ifndef INCLUDED_C_ALLOCATOR_H #include #endif /*INCLUDED_C_ALLOCATOR_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ typedef struct { c_SmartPtr_t* array; c_size_t capacity; c_size_t size; c_Allocator_t allocator; }c_SmartPtrVector_t; #define C_SMART_PTR_VECTOR_INITIALIZER {NULL, 0, 0, c_DefaultAllocator} /* ------------------------------------------------------------------------------------------------------------------ */ /* */ C_STATIC_FORCE_INLINE c_SmartPtrVector_t c_SmartPtrVector_Create(void) { return (c_SmartPtrVector_t)C_SMART_PTR_VECTOR_INITIALIZER; } C_STATIC_FORCE_INLINE const c_SmartPtr_t* c_SmartPtrVector_Get(const c_SmartPtrVector_t* self, c_size_t index) { if (!self || index >= self->size) { return NULL; } return &self->array[index]; } c_err_t c_SmartPtrVector_Init(c_SmartPtrVector_t* vector, c_size_t capacity, c_Allocator_t* allocator); void c_SmartPtrVector_Destroy(c_SmartPtrVector_t* vector); c_err_t c_SmartPtrVector_PushBack(c_SmartPtrVector_t* vector, const c_SmartPtr_t* ptr); c_err_t c_SmartPtrVector_PopBack(c_SmartPtrVector_t* vector, c_SmartPtr_t* ptr); c_err_t c_SmartPtrVector_Remove(c_SmartPtrVector_t* self, c_size_t index); c_err_t c_SmartPtrVector_Insert(c_SmartPtrVector_t* vector, c_size_t index, const c_SmartPtr_t* ptr); c_err_t c_SmartPtrVector_RemoveAndTake(c_SmartPtrVector_t* self, c_size_t index, c_SmartPtr_t* ptr); #endif /*INCLUDED_C_SMARTPTRVECTOR_H*/