From 59826852e4c76597517d16f7aefcaae127e6e2bb Mon Sep 17 00:00:00 2001 From: masterexplorer Date: Tue, 27 Aug 2024 09:32:53 +0200 Subject: [PATCH] integer --- main.cpp | 11 +++++++++++ makefile | 4 ++++ turbolist.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 main.cpp create mode 100644 makefile create mode 100644 turbolist.h diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..8461732 --- /dev/null +++ b/main.cpp @@ -0,0 +1,11 @@ +// g++ main.cpp -o main + +#include +#include +#include"turbolist.h" + +int main() { + TurboList list(4); + printf("sizeof(int)> %d\n", sizeof(int)); + return 0; +} diff --git a/makefile b/makefile new file mode 100644 index 0000000..fa59c74 --- /dev/null +++ b/makefile @@ -0,0 +1,4 @@ +debug: + g++ main.cpp -o main +release: + g++ main.cpp -O2 main diff --git a/turbolist.h b/turbolist.h new file mode 100644 index 0000000..7a43581 --- /dev/null +++ b/turbolist.h @@ -0,0 +1,28 @@ +#include +#include + +class TurboList { + int *old; + int *nex; + + uint32_t mid; // non-inclusive . . . m + uint32_t end; // non-inclusive e . . . . + + uint32_t capacity; + uint32_t count; +public: + inline TurboList(uint32_t cap) noexcept : + old(nullptr), + mid(0), + end(0), + capacity(cap), + count(0) { + + nex = (int*) malloc(this->capacity * sizeof(uint32_t)); + } + + inline ~TurboList() noexcept { + if(nex) free(nex); + if(old) free(old); + } +};