#ifndef INCLUDED_C_STRINGLIST_H #define INCLUDED_C_STRINGLIST_H #ifndef INCLUDED_C_TYPES_H #include #endif /*INCLUDED_C_TYPES_H*/ #ifndef INCLUDED_C_ALLOCATOR_H #include #endif /*INCLUDED_C_ALLOCATOR_H*/ /* ------------------------------------------------------------------------------------------------------------------ */ /* */ typedef struct { char** strings; // Dynamic array of self-owned null-terminated strings c_size_t size; // Current active string rows stored c_size_t capacity; // Max allocated capacity bounds of the internal pointer matrix c_Allocator_t allocator; } c_StringList_t; /* ------------------------------------------------------------------------------------------------------------------ */ /* */ c_err_t c_StringList_Init(c_StringList_t* self, c_size_t capacity, c_Allocator_t* allocator); void c_StringList_Destroy(c_StringList_t* self); // 核心操作 API (安全深拷贝值复制模式) c_err_t c_StringList_Add(c_StringList_t* self, const char* str); c_err_t c_StringList_InsertAt(c_StringList_t* self, c_size_t index, const char* str); c_err_t c_StringList_RemoveAt(c_StringList_t* self, c_size_t index); void c_StringList_Clear(c_StringList_t* self); // 高级功能接口 c_err_t c_StringList_Clone(c_StringList_t* dest, const c_StringList_t* src); c_err_t c_StringList_Deduplicate(c_StringList_t* self); // 极致高频内联只读窥探接口 C_STATIC_FORCE_INLINE c_size_t c_StringList_Size(const c_StringList_t* self) { return self ? self->size : 0; // O(1) 实时读取 } C_STATIC_FORCE_INLINE const char* c_StringList_Get(const c_StringList_t* self, c_size_t index) { if (!self || index >= self->size || !self->strings) return NULL; return self->strings[index]; // 零拷贝原位返回 } #endif /*INCLUDED_C_STRINGLIST_H*/