diff --git a/uppsrc/Core/InVector.h b/uppsrc/Core/InVector.h index be18c37f5..a33839fff 100644 --- a/uppsrc/Core/InVector.h +++ b/uppsrc/Core/InVector.h @@ -33,9 +33,9 @@ private: void Reset(); - void SetIter(ConstIterator& it, int ii); - void SetBegin(ConstIterator& it); - void SetEnd(ConstIterator& it); + void SetIter(ConstIterator& it, int ii) const; + void SetBegin(ConstIterator& it) const; + void SetEnd(ConstIterator& it) const; void Chk() const { ASSERT_(!IsPicked(), "Broken pick semantics"); } @@ -103,6 +103,8 @@ public: bool IsPicked() const { return data.IsPicked(); } InVector(const InVector& v, int); + + void Swap(InVector& b); STL_VECTOR_COMPATIBILITY(InVector) @@ -113,12 +115,12 @@ public: template class InVector::ConstIterator { - T *ptr; - T *begin; - T *end; - InVector *v; - int offset; - int blki; + const T *ptr; + const T *begin; + const T *end; + const InVector *v; + int offset; + int blki; friend class InVector; friend class InVector::Iterator; @@ -173,8 +175,8 @@ public: int operator-(const Iterator& x) const { return B::GetIndex() - x.GetIndex(); } - T& operator*() { return *B::ptr; } - T *operator->() { return B::ptr; } + T& operator*() { return *(T*)B::ptr; } + T *operator->() { return (T*)B::ptr; } T& operator[](int i) { Iterator h = *this; h += i; return *h; } const T& operator*() const { return *B::ptr; } @@ -293,6 +295,8 @@ public: InArray(const InArray& v, int); ~InArray() { Free(); } + void Swap(InArray& b) { iv.Swap(b.iv); } + STL_VECTOR_COMPATIBILITY(InArray) #ifdef _DEBUG diff --git a/uppsrc/Core/InVector.hpp b/uppsrc/Core/InVector.hpp index bb10033e7..cde17bb79 100644 --- a/uppsrc/Core/InVector.hpp +++ b/uppsrc/Core/InVector.hpp @@ -480,7 +480,7 @@ int InVector::Find(const T& val, const L& less) template -void InVector::SetIter(ConstIterator& it, int ii) +void InVector::SetIter(ConstIterator& it, int ii) const { if(count) { it.v = this; @@ -494,7 +494,7 @@ void InVector::SetIter(ConstIterator& it, int ii) } template -void InVector::SetBegin(ConstIterator& it) +void InVector::SetBegin(ConstIterator& it) const { if(count) { it.v = this; @@ -508,7 +508,7 @@ void InVector::SetBegin(ConstIterator& it) } template -void InVector::SetEnd(ConstIterator& it) +void InVector::SetEnd(ConstIterator& it) const { if(count) { it.v = this; @@ -557,6 +557,18 @@ void InVector::ConstIterator::PrevBlk() offset -= v->data[blki].GetCount(); } +template +void InVector::Swap(InVector& b) +{ + Swap(data, b.data); + Swap(index, b.index); + Swap(count, b.count); + Swap(hcount, b.hcount); + Swap(serial, b.serial); + Swap(blk_high, b.blk_high); + Swap(blk_low, b.blk_low); +} + #ifdef _DEBUG template void InVector::DumpIndex()