diff --git a/DataStructures/DeallocatingVector.h b/DataStructures/DeallocatingVector.h index 28f9480e5..cf9421d16 100644 --- a/DataStructures/DeallocatingVector.h +++ b/DataStructures/DeallocatingVector.h @@ -49,6 +49,7 @@ protected: ElementT * mData; size_t mIndex; std::vector & mBucketList; + inline void setPointerForIndex() { if(bucketSizeC*mBucketList.size() <= mIndex) { mData = DEALLOCATION_VECTOR_NULL_PTR; @@ -102,7 +103,9 @@ public: template DeallocatingVectorIterator(const DeallocatingVectorIterator & r) : mState(r.mState) {} + DeallocatingVectorIterator(size_t idx, std::vector & input_list) : mState(idx, input_list) {} + //DeallocatingVectorIterator(size_t idx, const std::vector & input_list) : mState(idx, input_list) {} DeallocatingVectorIterator(const DeallocatingVectorIteratorState & r) : mState(r) {} template @@ -231,6 +234,28 @@ public: ++mCurrentSize; } + inline void reserve(const size_t new_size) const { + //don't do anything + } + + inline void resize(const size_t new_size) { + if(new_size > mCurrentSize) { + while(capacity() < new_size) { + mBucketList.push_back(new ElementT[bucketSizeC]); + } + mCurrentSize = new_size; + } + if(new_size < mCurrentSize) { + size_t number_of_necessary_buckets = 1+(new_size / bucketSizeC); + + for(unsigned i = number_of_necessary_buckets; i < mBucketList.size(); ++i) { + delete[] mBucketList[i]; + } + mBucketList.resize(number_of_necessary_buckets); + mCurrentSize = new_size; + } + } + inline size_t size() const { return mCurrentSize; } @@ -276,6 +301,4 @@ public: } }; - - #endif /* DEALLOCATINGVECTOR_H_ */