more array list functions

This commit is contained in:
Gregory Wells
2025-06-17 11:58:14 -04:00
parent 9edc972b37
commit a8fa3e4da0

View File

@@ -20,6 +20,18 @@ int newCount = count - (list->maxSize - list->count);\
list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \ list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \
list->maxSize += newCount; \ list->maxSize += newCount; \
}\ }\
inline static void type##ArrayListExpand(type##ArrayList* list, int count) { \
list->data = realloc(list->data, sizeof(type) * (count + list->maxSize)); \
list->maxSize += count; \
}\
inline static void type##ArrayListAdd(type##ArrayList* list, type data) { \
if (list->count >= list->maxSize) {\
list->maxSize *= 2; \
list->data = realloc(list->data, sizeof(type) * list->maxSize); \
} \
list->data[list->count] = data;\
list->count++;\
}\
inline static void type##ArrayListResize(type##ArrayList* list, int count) { \ inline static void type##ArrayListResize(type##ArrayList* list, int count) { \
int newCount = count - (list->maxSize - list->count);\ int newCount = count - (list->maxSize - list->count);\
list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \ list->data = realloc(list->data, sizeof(type) * (newCount + list->maxSize)); \