diff --git a/TurboList.hpp b/TurboList.hpp index 8092ef2..f38cfbc 100644 --- a/TurboList.hpp +++ b/TurboList.hpp @@ -24,7 +24,6 @@ class TurboList { uint32_t end; // non-inclusive e . . . . uint32_t capacity; - uint32_t count; TL_NOINLINE void grow_and_insert(int elem) noexcept { // assert(mid == 0); @@ -43,8 +42,7 @@ public: old(nullptr), mid(0), end(0), - capacity(initial_cap), - count(0) { + capacity(initial_cap) { nex = (int *) malloc(this->capacity * sizeof(int)); } @@ -59,7 +57,7 @@ public: } inline void insert(int elem) noexcept { - if(TL_LIKELY(count < capacity)) { + if(TL_LIKELY(size() < capacity)) { // INSERT /* Same as this: @@ -73,7 +71,6 @@ public: nex[mid] = hasmid ? old[mid] : nex[mid]; nex[end++] = elem; - ++count; } else { // GROW @@ -82,7 +79,7 @@ public: } inline uint32_t size() noexcept { - return count; + return mid + (capacity - end - 1); } };