ソースを参照

Imports for List, List cleanup

Kajetan Johannes Hammerle 11 ヶ月 前
コミット
ca0e213fc6
8 ファイル変更241 行追加385 行削除
  1. 40 36
      include/core/List.h
  2. 7 1
      include/core/ToString.h
  3. 1 0
      include/core/Types.h
  4. 16 15
      src/Components.c
  5. 27 103
      src/List.c
  6. 23 6
      src/ToString.c
  7. 2 0
      test/Main.c
  8. 125 224
      test/modules/ListTests.c

+ 40 - 36
include/core/List.h

@@ -3,48 +3,52 @@
 
 #include "core/Types.h"
 
-typedef struct {
+struct CoreListT {
     size_t length;
     size_t capacity;
     size_t dataSize;
     void* data;
-} CoreList;
+};
+typedef struct CoreListT CoreList;
 
-#define CORE_LIST(dataSize) ((CoreList){0, 0, dataSize, nullptr})
-void coreCopyList(CoreList* l, const CoreList* other);
-void coreMoveList(CoreList* l, CoreList* other);
+void coreInitList(CoreList* l, size_t dataSize);
 void coreDestroyList(CoreList* l);
-void coreListReserve(CoreList* l, size_t n);
-void coreShrinkList(CoreList* l);
-void coreResizeList(CoreList* l, size_t n);
-void coreResizeListPointer(CoreList* l, size_t n, const void* data);
-#define coreResizeListV(l, n, type, ...)                                       \
-    coreResizeListPointer(l, n, &(type){__VA_ARGS__})
-CoreList* coreListAddPointer(CoreList* l, const void* data);
-#define coreListAdd(l, type, ...) coreListAddPointer(l, &(type){__VA_ARGS__})
-CoreList* coreListAddLast(CoreList* l);
-void* coreListAddEmpty(CoreList* l);
-void* coreListGetVoidPointer(CoreList* l, size_t index);
-#define coreListGetPointer(l, index, type)                                     \
-    ((type*)coreListGetVoidPointer(l, index))
-#define coreListGet(l, index, type) (*coreListGetPointer(l, index, type))
-const void* coreListGetVoidPointerC(const CoreList* l, size_t index);
-#define coreListGetPointerC(l, index, type)                                    \
-    ((const type*)coreListGetVoidPointerC(l, index))
-#define coreListGetC(l, index, type) (*coreListGetPointerC(l, index, type))
-void* coreListLastVoidPointer(CoreList* l);
-#define coreListLastPointer(l, type) ((type*)coreListLastVoidPointer(l))
-#define coreListLast(l, type) (*coreListLastPointer(l, type))
-const void* coreListLastVoidPointerC(const CoreList* l);
-#define coreListLastPointerC(l, type) ((const type*)coreListLastVoidPointerC(l))
-#define coreListLastC(l, type) (*coreListLastPointerC(l, type))
+void coreReserveListEntries(CoreList* l, size_t n);
+void coreAddListData(CoreList* l, const void* data);
+#define coreAddListType(l, type, ...) coreAddListData(l, &(type){__VA_ARGS__})
+void coreAddLastListData(CoreList* l);
+void* coreAddEmptyListData(CoreList* l);
+void* coreGetListIndex(const CoreList* l, size_t index);
+#define coreGetTypedListIndex(l, index, type)                                  \
+    (*(type*)coreGetListIndex(l, index))
+void* coreGetListLast(const CoreList* l);
+#define coreGetTypedListLast(l, type) (*(type*)coreGetListLast(l))
 void coreClearList(CoreList* l);
-void coreListRemoveBySwap(CoreList* l, size_t index);
-void coreListRemove(CoreList* l, size_t index);
-void coreListRemoveLast(CoreList* l);
-size_t coreToStringList(CoreList* l, char* buffer, size_t n, CoreToString c);
-void coreSwapList(CoreList* a, CoreList* b);
-void* coreListBegin(CoreList* l);
-void* coreListEnd(CoreList* l);
+void coreRemoveListIndexBySwap(CoreList* l, size_t index);
+void coreRemoveListIndex(CoreList* l, size_t index);
+void coreRemoveListLast(CoreList* l);
+void* coreGetListStart(const CoreList* l);
+void* coreGetListEnd(const CoreList* l);
+
+#ifdef IMPORT_CORE
+#define List CoreList
+#define initList coreInitList
+#define destroyList coreDestroyList
+#define reserveListEntries coreReserveListEntries
+#define addListData coreAddListData
+#define addListType coreAddListType
+#define addLastListData coreAddLastListData
+#define addEmptyListData coreAddEmptyListData
+#define getListIndex coreGetListIndex
+#define getTypedListIndex coreGetTypedListIndex
+#define getListLast coreGetListLast
+#define getTypedListLast coreGetTypedListLast
+#define clearList coreClearList
+#define removeListIndexBySwap coreRemoveListIndexBySwap
+#define removeListIndex coreRemoveListIndex
+#define removeListLast coreRemoveListLast
+#define getListStart coreGetListStart
+#define getListEnd coreGetListEnd
+#endif
 
 #endif

+ 7 - 1
include/core/ToString.h

@@ -10,6 +10,10 @@ size_t coreToStringSize(const void* p, char* buffer, size_t n);
 size_t coreToStringInt(const void* p, char* buffer, size_t n);
 void coreStringAdd(size_t* w, char** buffer, size_t* n, size_t shift);
 
+struct CoreListT;
+size_t coreToStringList(const struct CoreListT* l, char* buffer, size_t n,
+                        CoreToString c);
+
 #define CORE_STRUCT_TO_STRING(type)                                            \
     struct Core##type##T;                                                      \
     size_t coreToString##type(const struct Core##type##T* a, char* buffer,     \
@@ -24,6 +28,7 @@ CORE_STRUCT_TO_STRING(Plane)
 #define toStringSize coreToStringSize
 #define toStringInt coreToStringInt
 #define stringAdd coreStringAdd
+#define toStringList coreToStringList
 #define toStringBitArray coreToStringBitArray
 #define toStringBox coreToStringBox
 #define toStringMatrix coreToStringMatrix
@@ -42,7 +47,8 @@ CORE_STRUCT_TO_STRING(Plane)
         CORE_STRUCT_PAIR(BitArray),                                            \
         CORE_STRUCT_PAIR(Box),                                                 \
         CORE_STRUCT_PAIR(Matrix),                                              \
-        CORE_STRUCT_PAIR(Plane))(t, __VA_ARGS__)
+        CORE_STRUCT_PAIR(Plane),                                               \
+        CORE_STRUCT_PAIR(List))(t, __VA_ARGS__)
 #endif
 
 #endif

+ 1 - 0
include/core/Types.h

@@ -18,6 +18,7 @@ typedef size_t (*CoreToString)(const void* data, char* buffer, size_t n);
 
 #ifdef IMPORT_CORE
 #define ARRAY_LENGTH CORE_ARRAY_LENGTH
+#define ToString CoreToString
 #endif
 
 #endif

+ 16 - 15
src/Components.c

@@ -2,8 +2,8 @@
 
 void coreInitComponents(CoreComponents* c, size_t componentSize) {
     coreInitHashMap(&c->entityToIndex, sizeof(CoreEntity), sizeof(size_t));
-    c->indexToEntity = CORE_LIST(sizeof(CoreEntity));
-    c->components = CORE_LIST(componentSize);
+    coreInitList(&c->indexToEntity, sizeof(CoreEntity));
+    coreInitList(&c->components, componentSize);
 }
 
 void coreDestroyComponents(CoreComponents* c) {
@@ -19,8 +19,8 @@ void* coreComponentsGetOrAdd(CoreComponents* c, CoreEntity e) {
     }
     size_t index = c->components.length;
     coreHashMapPutPointer(&c->entityToIndex, &e, &index);
-    coreListAddPointer(&c->indexToEntity, &e);
-    return coreListAddEmpty(&c->components);
+    coreAddListData(&c->indexToEntity, &e);
+    return coreAddEmptyListData(&c->components);
 }
 
 void* coreComponentsSearch(CoreComponents* c, CoreEntity e) {
@@ -28,7 +28,7 @@ void* coreComponentsSearch(CoreComponents* c, CoreEntity e) {
     if(index == nullptr) {
         return nullptr;
     }
-    return coreListGetVoidPointer(&c->components, *index);
+    return coreGetListIndex(&c->components, *index);
 }
 
 bool coreComponentsRemove(CoreComponents* c, CoreEntity e) {
@@ -39,22 +39,23 @@ bool coreComponentsRemove(CoreComponents* c, CoreEntity e) {
     size_t lastIndex = c->components.length - 1;
     size_t index = *indexP;
     coreHashMapRemovePointer(&c->entityToIndex, &e);
-    coreListRemoveBySwap(&c->components, index);
+    coreRemoveListIndexBySwap(&c->components, index);
     if(index == lastIndex) {
-        coreListRemoveBySwap(&c->indexToEntity, index);
+        coreRemoveListIndexBySwap(&c->indexToEntity, index);
         return true;
     }
-    CoreEntity other = coreListGet(&c->indexToEntity, lastIndex, CoreEntity);
-    coreListRemoveBySwap(&c->indexToEntity, index);
+    CoreEntity other =
+        coreGetTypedListIndex(&c->indexToEntity, lastIndex, CoreEntity);
+    coreRemoveListIndexBySwap(&c->indexToEntity, index);
     coreHashMapPutPointer(&c->entityToIndex, &other, &index);
     return true;
 }
 
 void coreInitComponentsIterator(CoreComponentIterator* ci, CoreComponents* c) {
-    ci->indexToEntity = coreListBegin(&c->indexToEntity);
-    ci->indexToEntityEnd = coreListEnd(&c->indexToEntity);
-    ci->component = coreListBegin(&c->components);
-    ci->componentEnd = coreListEnd(&c->components);
+    ci->indexToEntity = coreGetListStart(&c->indexToEntity);
+    ci->indexToEntityEnd = coreGetListEnd(&c->indexToEntity);
+    ci->component = coreGetListStart(&c->components);
+    ci->componentEnd = coreGetListEnd(&c->components);
     ci->componentSize = c->components.dataSize;
     ci->node = (CoreComponentNode){0};
 }
@@ -72,9 +73,9 @@ CoreComponentNode* coreComponentsNext(CoreComponentIterator* ci) {
 }
 
 void* coreComponentsBegin(CoreComponents* c) {
-    return coreListBegin(&c->components);
+    return coreGetListStart(&c->components);
 }
 
 void* coreComponentsEnd(CoreComponents* c) {
-    return coreListEnd(&c->components);
+    return coreGetListEnd(&c->components);
 }

+ 27 - 103
src/List.c

@@ -7,117 +7,63 @@
 #include "core/ToString.h"
 #include "core/Utility.h"
 
-static void ensureCapacity(CoreList* l) {
+static void ensureCapacity(List* l) {
     if(l->length >= l->capacity) {
-        coreListReserve(l, l->capacity + coreMaxSize(4lu, l->capacity / 4));
+        reserveListEntries(l, l->capacity + maxSize(4lu, l->capacity / 4));
     }
 }
 
-static void setSize(CoreList* l, size_t n) {
+static void setSize(List* l, size_t n) {
     l->capacity = n;
-    l->data = coreReallocate(l->data, l->dataSize * n);
+    l->data = cReallocate(l->data, l->dataSize * n);
 }
 
-static void* getPointer(CoreList* l, size_t index) {
+static void* getPointer(const List* l, size_t index) {
     return (char*)l->data + (l->dataSize * index);
 }
 
-static const void* getPointerC(const CoreList* l, size_t index) {
-    return (const char*)l->data + (l->dataSize * index);
+void initList(List* l, size_t dataSize) {
+    *l = (List){0, 0, dataSize, nullptr};
 }
 
-void coreCopyList(CoreList* l, const CoreList* other) {
-    if(l == other) {
-        return;
-    }
-    coreDestroyList(l);
-    l->length = other->length;
-    l->dataSize = other->dataSize;
-    setSize(l, other->capacity);
-    memcpy(l->data, other->data, l->dataSize * l->length);
-}
-
-void coreMoveList(CoreList* l, CoreList* other) {
-    if(l == other) {
-        return;
-    }
-    coreSwapList(l, other);
-    coreDestroyList(other);
+void destroyList(List* l) {
+    cFree(l->data);
+    *l = (List){0};
 }
 
-void coreDestroyList(CoreList* l) {
-    coreFree(l->data);
-    *l = CORE_LIST(0);
-}
-
-void coreListReserve(CoreList* l, size_t n) {
+void reserveListEntries(List* l, size_t n) {
     if(n > l->capacity) {
         setSize(l, n);
     }
 }
 
-void coreShrinkList(CoreList* l) {
-    if(l->length != l->capacity) {
-        setSize(l, l->length);
-    }
-}
-
-void coreResizeList(CoreList* l, size_t n) {
-    if(l->length < n) {
-        coreListReserve(l, n);
-        memset(getPointer(l, l->length), 0, (n - l->length) * l->dataSize);
-    }
-    l->length = n;
-}
-
-void coreResizeListPointer(CoreList* l, size_t n, const void* data) {
-    if(l->length < n) {
-        coreListReserve(l, n);
-        while(l->length < n) {
-            coreListAddPointer(l, data);
-        }
-    } else if(l->length > n) {
-        l->length = n;
-    }
-}
-
-CoreList* coreListAddPointer(CoreList* l, const void* data) {
-    memcpy(coreListAddEmpty(l), data, l->dataSize);
-    return l;
+void addListData(List* l, const void* data) {
+    memcpy(addEmptyListData(l), data, l->dataSize);
 }
 
-CoreList* coreListAddLast(CoreList* l) {
-    return coreListAddPointer(l, coreListLastVoidPointer(l));
+void addLastListData(List* l) {
+    addListData(l, getListLast(l));
 }
 
-void* coreListAddEmpty(CoreList* l) {
+void* addEmptyListData(List* l) {
     ensureCapacity(l);
     return getPointer(l, l->length++);
 }
 
-void* coreListGetVoidPointer(CoreList* l, size_t index) {
+void* getListIndex(const List* l, size_t index) {
     assert(index < l->length);
     return getPointer(l, index);
 }
 
-const void* coreListGetVoidPointerC(const CoreList* l, size_t index) {
-    assert(index < l->length);
-    return getPointerC(l, index);
-}
-
-void* coreListLastVoidPointer(CoreList* l) {
-    return coreListGetVoidPointer(l, l->length - 1);
-}
-
-const void* coreListLastVoidPointerC(const CoreList* l) {
-    return coreListGetVoidPointerC(l, l->length - 1);
+void* getListLast(const List* l) {
+    return getListIndex(l, l->length - 1);
 }
 
-void coreClearList(CoreList* l) {
+void clearList(List* l) {
     l->length = 0;
 }
 
-void coreListRemoveBySwap(CoreList* l, size_t index) {
+void removeListIndexBySwap(List* l, size_t index) {
     assert(index < l->length);
     size_t length = l->length - 1;
     if(index != length) {
@@ -126,47 +72,25 @@ void coreListRemoveBySwap(CoreList* l, size_t index) {
     l->length = length;
 }
 
-void coreListRemove(CoreList* l, size_t index) {
+void removeListIndex(List* l, size_t index) {
     assert(index < l->length);
     l->length--;
     char* p = getPointer(l, index);
-    char* end = coreListEnd(l);
+    char* end = getListEnd(l);
     while(p != end) {
         *p = *(p + l->dataSize);
         p++;
     }
 }
 
-void coreListRemoveLast(CoreList* l) {
-    coreListRemoveBySwap(l, l->length - 1);
-}
-
-size_t coreToStringList(CoreList* l, char* buffer, size_t n, CoreToString c) {
-    size_t w = 0;
-    coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, "["));
-    char* end = coreListEnd(l);
-    char* p = coreListBegin(l);
-    while(p != end) {
-        coreStringAdd(&w, &buffer, &n, c(p, buffer, n));
-        p += l->dataSize;
-        if(p != end) {
-            coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, ", "));
-        }
-    }
-    coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, "]"));
-    return w;
-}
-
-void coreSwapList(CoreList* a, CoreList* b) {
-    CoreList tmp = *a;
-    *a = *b;
-    *b = tmp;
+void removeListLast(List* l) {
+    removeListIndexBySwap(l, l->length - 1);
 }
 
-void* coreListBegin(CoreList* l) {
+void* getListStart(const List* l) {
     return l->data;
 }
 
-void* coreListEnd(CoreList* l) {
+void* getListEnd(const List* l) {
     return getPointer(l, l->length);
 }

+ 23 - 6
src/ToString.c

@@ -5,6 +5,7 @@
 
 #include "core/BitArray.h"
 #include "core/Box.h"
+#include "core/List.h"
 #include "core/Matrix.h"
 #include "core/Plane.h"
 #include "core/Utility.h"
@@ -37,22 +38,22 @@ void stringAdd(size_t* w, char** buffer, size_t* n, size_t shift) {
 
 size_t toStringBitArray(const BitArray* a, char* buffer, size_t n) {
     size_t w = 0;
-    coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, "["));
+    stringAdd(&w, &buffer, &n, coreToString(buffer, n, "["));
     size_t length = a->length;
     if(length > 0) {
         length--;
         for(size_t i = 0; i < length; i++) {
             u64 v = getBits(a, i);
-            coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, "%lu, ", v));
+            stringAdd(&w, &buffer, &n, coreToString(buffer, n, "%lu, ", v));
         }
         u64 v = getBits(a, length);
-        coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, "%lu", v));
+        stringAdd(&w, &buffer, &n, coreToString(buffer, n, "%lu", v));
     }
-    coreStringAdd(&w, &buffer, &n, coreToString(buffer, n, "]"));
+    stringAdd(&w, &buffer, &n, coreToString(buffer, n, "]"));
     return w;
 }
 
-size_t coreToStringBox(const CoreBox* box, char* buffer, size_t n) {
+size_t toStringBox(const Box* box, char* buffer, size_t n) {
     return coreToString(buffer, n,
                         "Box([%.3f, %.3f, %.3f], [%.3f, %.3f, %.3f])",
                         (double)box->min.data[0], (double)box->min.data[1],
@@ -74,8 +75,24 @@ size_t toStringMatrix(const Matrix* m, char* buffer, size_t n) {
     return w;
 }
 
-size_t coreToStringPlane(const Plane* p, char* buffer, size_t n) {
+size_t toStringPlane(const Plane* p, char* buffer, size_t n) {
     return coreToString(buffer, n, "(%.3f x + %.3f y + %.3f z + %.3f)",
                         (double)p->abc.data[0], (double)p->abc.data[1],
                         (double)p->abc.data[2], (double)p->d);
 }
+
+size_t toStringList(const List* l, char* buffer, size_t n, ToString c) {
+    size_t w = 0;
+    stringAdd(&w, &buffer, &n, coreToString(buffer, n, "["));
+    char* end = getListEnd(l);
+    char* p = getListStart(l);
+    while(p != end) {
+        stringAdd(&w, &buffer, &n, c(p, buffer, n));
+        p += l->dataSize;
+        if(p != end) {
+            stringAdd(&w, &buffer, &n, coreToString(buffer, n, ", "));
+        }
+    }
+    stringAdd(&w, &buffer, &n, coreToString(buffer, n, "]"));
+    return w;
+}

+ 2 - 0
test/Main.c

@@ -45,7 +45,9 @@ int main(int argAmount, const char** args) {
     testPlane();
     testQuaternion();
     testRandom(light);
+    logLevel = LOG_ERROR;
     testReadLine();
+    logLevel = LOG_DEBUG;
     testRingBuffer();
     testSpinLock();
     testUtility(light);

+ 125 - 224
test/modules/ListTests.c

@@ -1,272 +1,181 @@
 #include "../Tests.h"
 #include "core/List.h"
 #include "core/ToString.h"
-#include "core/Utility.h"
 #include "core/Vector.h"
 
 static void testAdd() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 5);
-    CORE_TEST_SIZE(5, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(5, coreListGetC(&list, 0, size_t));
-    CORE_TEST_SIZE(1, list.length);
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 5);
+    TEST_SIZE(5, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(1, list.length);
+    destroyList(&list);
 }
 
 static void testMultipleAdd() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 4);
-    coreListAdd(&list, size_t, 3);
-    coreListAdd(&list, size_t, 2);
-    CORE_TEST_SIZE(4, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&list, 1, size_t));
-    CORE_TEST_SIZE(2, coreListGet(&list, 2, size_t));
-    CORE_TEST_SIZE(2, coreListLast(&list, size_t));
-    CORE_TEST_SIZE(4, coreListGetC(&list, 0, size_t));
-    CORE_TEST_SIZE(3, coreListGetC(&list, 1, size_t));
-    CORE_TEST_SIZE(2, coreListGetC(&list, 2, size_t));
-    CORE_TEST_SIZE(2, coreListLastC(&list, size_t));
-    CORE_TEST_SIZE(3, list.length);
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 4);
+    addListType(&list, size_t, 3);
+    addListType(&list, size_t, 2);
+    TEST_SIZE(4, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(3, getTypedListIndex(&list, 1, size_t));
+    TEST_SIZE(2, getTypedListIndex(&list, 2, size_t));
+    TEST_SIZE(2, getTypedListLast(&list, size_t));
+    TEST_SIZE(3, list.length);
+    destroyList(&list);
 }
 
 static void testAddLast() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 4);
-    coreListAdd(&list, size_t, 3);
-    coreListAddLast(&list);
-    CORE_TEST_SIZE(4, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&list, 1, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&list, 2, size_t));
-    CORE_TEST_SIZE(3, list.length);
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 4);
+    addListType(&list, size_t, 3);
+    addLastListData(&list);
+    TEST_SIZE(4, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(3, getTypedListIndex(&list, 1, size_t));
+    TEST_SIZE(3, getTypedListIndex(&list, 2, size_t));
+    TEST_SIZE(3, list.length);
+    destroyList(&list);
 }
 
 static void testAddReplace() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 5);
-    coreListGet(&list, 0, size_t) = 3;
-    CORE_TEST_SIZE(3, coreListGet(&list, 0, size_t));
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 5);
+    getTypedListIndex(&list, 0, size_t) = 3;
+    TEST_SIZE(3, getTypedListIndex(&list, 0, size_t));
+    destroyList(&list);
 }
 
 static void testClear() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 5);
-    coreListAdd(&list, size_t, 4);
-    coreClearList(&list);
-    CORE_TEST_SIZE(0, list.length);
-    coreDestroyList(&list);
-}
-
-static void testShrink() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 5);
-    coreListAdd(&list, size_t, 4);
-    coreListAdd(&list, size_t, 3);
-    CORE_TEST_TRUE(list.capacity >= 3);
-    coreShrinkList(&list);
-    CORE_TEST_SIZE(3, list.length);
-    CORE_TEST_SIZE(3, list.capacity);
-    CORE_TEST_SIZE(5, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(4, coreListGet(&list, 1, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&list, 2, size_t));
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 5);
+    addListType(&list, size_t, 4);
+    clearList(&list);
+    TEST_SIZE(0, list.length);
+    destroyList(&list);
 }
 
 static void testBigAdd(bool light) {
     size_t limit = light ? 10000 : 100000;
-    CoreList list = CORE_LIST(sizeof(size_t));
+    List list;
+    initList(&list, sizeof(size_t));
     for(size_t i = 0; i < limit; i++) {
-        coreListAdd(&list, size_t, i);
+        addListType(&list, size_t, i);
     }
     for(size_t i = 0; i < list.length; i++) {
-        CORE_TEST_SIZE(i, coreListGet(&list, i, size_t));
+        TEST_SIZE(i, getTypedListIndex(&list, i, size_t));
     }
-    CORE_TEST_SIZE(limit, list.length);
-    coreDestroyList(&list);
-}
-
-static void testCopy() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 1);
-    coreListAdd(&list, size_t, 2);
-    coreListAdd(&list, size_t, 3);
-
-    CoreList copy = CORE_LIST(0);
-    coreCopyList(&copy, &list);
-    coreCopyList(&copy, &copy);
-    CORE_TEST_SIZE(list.length, copy.length);
-    size_t limit = coreMinSize(copy.length, list.length);
-    for(size_t i = 0; i < limit; i++) {
-        CORE_TEST_SIZE(coreListGet(&list, i, size_t),
-                       coreListGet(&copy, i, size_t));
-    }
-    coreDestroyList(&copy);
-    coreDestroyList(&list);
-}
-
-static void testMove() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 1);
-    coreListAdd(&list, size_t, 2);
-    coreListAdd(&list, size_t, 3);
-
-    CoreList move = CORE_LIST(0);
-    coreMoveList(&move, &list);
-    coreMoveList(&move, &move);
-    CORE_TEST_SIZE(0, list.length);
-    CORE_TEST_SIZE(3, move.length);
-    CORE_TEST_SIZE(1, coreListGet(&move, 0, size_t));
-    CORE_TEST_SIZE(2, coreListGet(&move, 1, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&move, 2, size_t));
-    coreDestroyList(&move);
+    TEST_SIZE(limit, list.length);
+    destroyList(&list);
 }
 
 static void testToString1() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 1);
-    coreListAdd(&list, size_t, 243);
-    coreListAdd(&list, size_t, 423);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 1);
+    addListType(&list, size_t, 243);
+    addListType(&list, size_t, 423);
     char buffer[128];
-    size_t n =
-        coreToStringList(&list, buffer, sizeof(buffer), coreToStringSize);
-    CORE_TEST_SIZE(13, n);
-    CORE_TEST_STRING("[1, 243, 423]", buffer);
-    coreDestroyList(&list);
+    size_t n = toString(&list, buffer, sizeof(buffer), toStringSize);
+    TEST_SIZE(13, n);
+    TEST_STRING("[1, 243, 423]", buffer);
+    destroyList(&list);
 }
 
 static void testToString2() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 1);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 1);
     char buffer[128];
-    size_t n =
-        coreToStringList(&list, buffer, sizeof(buffer), coreToStringSize);
-    CORE_TEST_SIZE(3, n);
-    CORE_TEST_STRING("[1]", buffer);
-    coreDestroyList(&list);
+    size_t n = toString(&list, buffer, sizeof(buffer), toStringSize);
+    TEST_SIZE(3, n);
+    TEST_STRING("[1]", buffer);
+    destroyList(&list);
 }
 
 static void testToString3() {
-    CoreList list = CORE_LIST(sizeof(size_t));
+    List list;
+    initList(&list, sizeof(size_t));
     char buffer[128];
-    size_t n =
-        coreToStringList(&list, buffer, sizeof(buffer), coreToStringSize);
-    CORE_TEST_SIZE(2, n);
-    CORE_TEST_STRING("[]", buffer);
-    coreDestroyList(&list);
+    size_t n = toString(&list, buffer, sizeof(buffer), toStringSize);
+    TEST_SIZE(2, n);
+    TEST_STRING("[]", buffer);
+    destroyList(&list);
 }
 
 static void testRemoveBySwap() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 4);
-    coreListAdd(&list, size_t, 3);
-    coreListAdd(&list, size_t, 2);
-    coreListRemoveBySwap(&list, 0);
-    CORE_TEST_SIZE(2, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&list, 1, size_t));
-    CORE_TEST_SIZE(2, list.length);
-    coreListRemoveBySwap(&list, 1);
-    CORE_TEST_SIZE(2, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(1, list.length);
-    coreListRemoveBySwap(&list, 0);
-    CORE_TEST_SIZE(0, list.length);
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 4);
+    addListType(&list, size_t, 3);
+    addListType(&list, size_t, 2);
+    removeListIndexBySwap(&list, 0);
+    TEST_SIZE(2, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(3, getTypedListIndex(&list, 1, size_t));
+    TEST_SIZE(2, list.length);
+    removeListIndexBySwap(&list, 1);
+    TEST_SIZE(2, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(1, list.length);
+    removeListIndexBySwap(&list, 0);
+    TEST_SIZE(0, list.length);
+    destroyList(&list);
 }
 
 static void testRemove() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 4);
-    coreListAdd(&list, size_t, 3);
-    coreListAdd(&list, size_t, 2);
-    coreListRemove(&list, 0);
-    CORE_TEST_SIZE(3, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(2, coreListGet(&list, 1, size_t));
-    CORE_TEST_SIZE(2, list.length);
-    coreListRemove(&list, 1);
-    CORE_TEST_SIZE(3, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(1, list.length);
-    coreListRemove(&list, 0);
-    CORE_TEST_SIZE(0, list.length);
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 4);
+    addListType(&list, size_t, 3);
+    addListType(&list, size_t, 2);
+    removeListIndex(&list, 0);
+    TEST_SIZE(3, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(2, getTypedListIndex(&list, 1, size_t));
+    TEST_SIZE(2, list.length);
+    removeListIndex(&list, 1);
+    TEST_SIZE(3, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(1, list.length);
+    removeListIndex(&list, 0);
+    TEST_SIZE(0, list.length);
+    destroyList(&list);
 }
 
 static void testRemoveLast() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListAdd(&list, size_t, 4);
-    coreListAdd(&list, size_t, 3);
-    coreListAdd(&list, size_t, 2);
-    coreListRemoveLast(&list);
-    CORE_TEST_SIZE(4, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(3, coreListGet(&list, 1, size_t));
-    CORE_TEST_SIZE(2, list.length);
-    coreListRemoveLast(&list);
-    CORE_TEST_SIZE(4, coreListGet(&list, 0, size_t));
-    CORE_TEST_SIZE(1, list.length);
-    coreListRemoveLast(&list);
-    CORE_TEST_SIZE(0, list.length);
-    coreDestroyList(&list);
-}
-
-static void testResize() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreResizeListV(&list, 5, size_t, 10);
-    CORE_TEST_SIZE(5, list.length);
-    for(size_t i = 0; i < 5; i++) {
-        CORE_TEST_SIZE(10, coreListGet(&list, i, size_t));
-    }
-    coreDestroyList(&list);
-}
-
-static void testDefaultResize() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreResizeList(&list, 5);
-    CORE_TEST_SIZE(5, list.length);
-    for(size_t i = 0; i < 5; i++) {
-        CORE_TEST_SIZE(0, coreListGet(&list, i, size_t));
-    }
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    addListType(&list, size_t, 4);
+    addListType(&list, size_t, 3);
+    addListType(&list, size_t, 2);
+    removeListLast(&list);
+    TEST_SIZE(4, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(3, getTypedListIndex(&list, 1, size_t));
+    TEST_SIZE(2, list.length);
+    removeListLast(&list);
+    TEST_SIZE(4, getTypedListIndex(&list, 0, size_t));
+    TEST_SIZE(1, list.length);
+    removeListLast(&list);
+    TEST_SIZE(0, list.length);
+    destroyList(&list);
 }
 
 static void testInvalidReserve() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreListReserve(&list, 0);
-    coreDestroyList(&list);
-}
-
-static void testShrinkExact() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreResizeList(&list, 50);
-    coreShrinkList(&list);
-    coreDestroyList(&list);
-}
-
-static void testShrinkResize() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    coreResizeList(&list, 50);
-    CORE_TEST_SIZE(50, list.length);
-    coreResizeListV(&list, 20, size_t, 5);
-    CORE_TEST_SIZE(20, list.length);
-    coreResizeList(&list, 10);
-    CORE_TEST_SIZE(10, list.length);
-    coreDestroyList(&list);
-}
-
-static void testCopyEmpty() {
-    CoreList list = CORE_LIST(sizeof(size_t));
-    CoreList copy = CORE_LIST(0);
-    coreCopyList(&copy, &list);
-    coreDestroyList(&copy);
-    coreDestroyList(&list);
+    List list;
+    initList(&list, sizeof(size_t));
+    reserveListEntries(&list, 0);
+    destroyList(&list);
 }
 
 static void testStruct() {
-    CoreList list = CORE_LIST(sizeof(CoreVector3));
-    CoreVector3 v = {{1, 2, 3}};
-    coreListAddPointer(&list, &v);
-    coreListAdd(&list, CoreVector3, {2, 3, 4});
-    CORE_TEST_V3(&v, coreListGetPointer(&list, 0, CoreVector3));
-    coreDestroyList(&list);
+    List list;
+    Vector3 v = {{1, 2, 3}};
+    initList(&list, sizeof(v));
+    addListData(&list, &v);
+    addListType(&list, Vector3, {2, 3, 4});
+    Vector3* entry = getListIndex(&list, 0);
+    TEST_V3(&v, entry);
+    destroyList(&list);
 }
 
 void testList(bool light) {
@@ -275,21 +184,13 @@ void testList(bool light) {
     testAddLast();
     testAddReplace();
     testClear();
-    testShrink();
     testBigAdd(light);
-    testCopy();
-    testMove();
     testToString1();
     testToString2();
     testToString3();
     testRemoveBySwap();
     testRemove();
     testRemoveLast();
-    testResize();
-    testDefaultResize();
     testInvalidReserve();
-    testShrinkExact();
-    testShrinkResize();
-    testCopyEmpty();
     testStruct();
 }