diff --git a/storm/array/TSFixedArray.hpp b/storm/array/TSFixedArray.hpp index 0a6ca36..647fcaf 100644 --- a/storm/array/TSFixedArray.hpp +++ b/storm/array/TSFixedArray.hpp @@ -9,7 +9,10 @@ template class TSFixedArray : public TSBaseArray { public: ~TSFixedArray(); + TSFixedArray& operator=(const TSFixedArray& source); + void ReallocAndClearData(uint32_t count); void ReallocData(uint32_t count); + void Set(uint32_t count, const T* data); void SetCount(uint32_t count); }; @@ -25,6 +28,25 @@ TSFixedArray::~TSFixedArray() { } } +template +TSFixedArray& TSFixedArray::operator=(const TSFixedArray& source) { + if (this != &source) { + this->Set(source.Count(), source.Ptr()); + } + + return *this; +} + +template +void TSFixedArray::ReallocAndClearData(uint32_t count) { + this->m_alloc = count; + + if (this->m_data || count) { + void* m = SMemReAlloc(this->m_data, sizeof(T) * count, this->MemFileName(), this->MemLineNo(), 0x0); + this->m_data = static_cast(m); + } +} + template void TSFixedArray::ReallocData(uint32_t count) { T* oldData = this->m_data; @@ -60,6 +82,17 @@ void TSFixedArray::ReallocData(uint32_t count) { } } +template +void TSFixedArray::Set(uint32_t count, const T* data) { + this->ReallocAndClearData(count); + + for (uint32_t i; i < count; i++) { + new (&this->m_data[i]) T(data[i]); + } + + this->m_count = count; +} + template void TSFixedArray::SetCount(uint32_t count) { if (count != this->m_count) {