From d91c5fe91642526112e0ce29499b96fb044c32a5 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Fri, 24 Mar 2023 23:45:08 -0500 Subject: [PATCH] feat(array): add getter for reserved entry count in growable arrays --- storm/array/TSGrowableArray.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/storm/array/TSGrowableArray.hpp b/storm/array/TSGrowableArray.hpp index f03c113..a091103 100644 --- a/storm/array/TSGrowableArray.hpp +++ b/storm/array/TSGrowableArray.hpp @@ -18,6 +18,7 @@ class TSGrowableArray : public TSFixedArray { void GrowToFit(uint32_t index, int32_t zero); T* New(void); void Reserve(uint32_t count, int32_t round); + uint32_t Reserved() const; uint32_t RoundToChunk(uint32_t count, uint32_t chunk); void SetCount(uint32_t count); }; @@ -112,6 +113,11 @@ void TSGrowableArray::Reserve(uint32_t count, int32_t round) { } } +template +uint32_t TSGrowableArray::Reserved() const { + return this->m_alloc - this->m_count; +} + template uint32_t TSGrowableArray::RoundToChunk(uint32_t count, uint32_t chunk) { if (count % chunk) {