List.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef CORE_LIST_H
  2. #define CORE_LIST_H
  3. #include "core/Types.h"
  4. struct CoreListT {
  5. size_t length;
  6. size_t capacity;
  7. size_t dataSize;
  8. void* data;
  9. };
  10. typedef struct CoreListT CoreList;
  11. void coreInitList(CoreList* l, size_t dataSize);
  12. void coreDestroyList(CoreList* l);
  13. void coreReserveListEntries(CoreList* l, size_t n);
  14. void coreAddListData(CoreList* l, const void* data);
  15. #define coreAddListType(l, type, ...) coreAddListData(l, &(type){__VA_ARGS__})
  16. void coreAddLastListData(CoreList* l);
  17. void* coreAddEmptyListData(CoreList* l);
  18. void* coreGetListIndex(const CoreList* l, size_t index);
  19. #define coreGetTypedListIndex(l, index, type) \
  20. (*(type*)coreGetListIndex(l, index))
  21. void* coreGetListLast(const CoreList* l);
  22. #define coreGetTypedListLast(l, type) (*(type*)coreGetListLast(l))
  23. void coreClearList(CoreList* l);
  24. void coreRemoveListIndexBySwap(CoreList* l, size_t index);
  25. void coreRemoveListIndex(CoreList* l, size_t index);
  26. void coreRemoveListLast(CoreList* l);
  27. void* coreGetListStart(const CoreList* l);
  28. void* coreGetListEnd(const CoreList* l);
  29. #ifdef IMPORT_CORE
  30. #define List CoreList
  31. #define initList coreInitList
  32. #define destroyList coreDestroyList
  33. #define reserveListEntries coreReserveListEntries
  34. #define addListData coreAddListData
  35. #define addListType coreAddListType
  36. #define addLastListData coreAddLastListData
  37. #define addEmptyListData coreAddEmptyListData
  38. #define getListIndex coreGetListIndex
  39. #define getTypedListIndex coreGetTypedListIndex
  40. #define getListLast coreGetListLast
  41. #define getTypedListLast coreGetTypedListLast
  42. #define clearList coreClearList
  43. #define removeListIndexBySwap coreRemoveListIndexBySwap
  44. #define removeListIndex coreRemoveListIndex
  45. #define removeListLast coreRemoveListLast
  46. #define getListStart coreGetListStart
  47. #define getListEnd coreGetListEnd
  48. #endif
  49. #endif