List.h 925 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef CORE_LIST_H
  2. #define CORE_LIST_H
  3. #include "core/Types.h"
  4. struct ListT {
  5. size_t length;
  6. size_t capacity;
  7. size_t dataSize;
  8. void* data;
  9. };
  10. typedef struct ListT List;
  11. void initList(List* l, size_t dataSize);
  12. void destroyList(List* l);
  13. void reserveListEntries(List* l, size_t n);
  14. void addListData(List* l, const void* data);
  15. #define addListType(l, type, ...) addListData(l, &(type){__VA_ARGS__})
  16. void addLastListData(List* l);
  17. void* addEmptyListData(List* l);
  18. void* getListIndex(const List* l, size_t index);
  19. #define getTypedListIndex(l, index, type) (*(type*)getListIndex(l, index))
  20. void* getListLast(const List* l);
  21. #define getTypedListLast(l, type) (*(type*)getListLast(l))
  22. void clearList(List* l);
  23. void removeListIndexBySwap(List* l, size_t index);
  24. void removeListIndex(List* l, size_t index);
  25. void removeListLast(List* l);
  26. void* getListStart(const List* l);
  27. void* getListEnd(const List* l);
  28. #endif