diff --git a/src/lists/gryphn_list.h b/src/lists/gryphn_list.h deleted file mode 100644 index 99fce45..0000000 --- a/src/lists/gryphn_list.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once -#include "math.h" -#include "stdio.h" - -// TODO: Wack ass list class, needs some serious refactoring, buttttt it works for what I need it to do -// Imma touch this later cuz like I dont like working with C code cuz its wierd but like its also fun -// who needs std::vector when you've got malloc, calloc, and free -// shit just forgot that I dont clean any of this up, imma do this later cuz like its boring -// ive decided to do it now, I hate this, I hate coding, C is fun, this is a Cpp file, what am I doing with life -// I never did it id be super easy just like one anitconstructor????? i dont remeber what is called its the one with the squigly bracked -// TODO: future me rewirte these comments to be less stupid -// TODO: Add insert function, also remove function, orrrrrr i could have people copy lists whever they wanna remove stuff, nah thats gunna piss me off too - -#define GRYPHN_LIST_GROWTH_RATE 2 // number straight from my ass I wanted to use 1.5f cuz thats what STL does but like it complained - // im in an abbusive relationship with the compiler, I need to get out of this - // but like I also kinda like it imma pick of drinking (not actually imma just play minecraft) - -template // fuck templates -struct gnList { -protected: - Type* items = nullptr; - int size = 0, max_size = 0; -public: - gnList() {} - - // why did I make shit protected - // theres gotta be a better way to do this with compiler macros but like that sounds hard - // im never touching this wack ass code ever again - template - friend gnList gnCreateList(int size); - template - friend void gnListAdd(gnList& list, T item); - template - friend int gnListLength(const gnList& list); - template - friend T& gnListGet(const gnList& list, int index); - template - friend T* gnListGetPtr(const gnList& list, int index); - template - friend void gnListSet(const gnList& list, int index, T item); - template - friend T* gnListData(const gnList& list); -public: - Type operator[](int index) const { return items[index]; } // idfk what that const is doin there but the compiler complained I was tryna change a const value - // .... I was not, I really am in an abusive relationship - Type& operator[](int index) { return items[index]; } -}; - -template -gnList gnCreateList(int size = 0) { - gnList new_list = gnList(); - new_list.size = size; - if (size == 0) size = round(GRYPHN_LIST_GROWTH_RATE); - new_list.items = (T*)malloc(sizeof(T) * size); - new_list.max_size = size; - return new_list; -} - -template -void gnListAdd(gnList& list, T item) { - if (gnListLength(list) == list.max_size) { - list.max_size = list.max_size * GRYPHN_LIST_GROWTH_RATE; - list.items = (T*)realloc(list.items, sizeof(T) * list.max_size); - } - - list.items[list.size] = item; - list.size++; -} - -template -int gnListLength(const gnList& list) { return list.size; } - -template -T& gnListGet(const gnList& list, int index) { return list.items[index]; } - -template -T* gnListGetPtr(const gnList& list, int index) { return &list.items[index]; } - -template -void gnListSet(const gnList& list, int index, T item) { list.items[index] = item; } - -template -T* gnListData(const gnList& list) { return list.items; } // wack ass function for binary shit - // if this ever breaks change it to return &list.items[0] cuz that might work - // I have zero clue what any of this shit does