Core: Some InVector fixes

git-svn-id: svn://ultimatepp.org/upp/trunk@5787 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-02-10 18:00:54 +00:00
parent 84b2c33ee8
commit ecbe402ed8
2 changed files with 30 additions and 14 deletions

View file

@ -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<T>)
@ -113,12 +115,12 @@ public:
template <class T>
class InVector<T>::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<T>;
friend class InVector<T>::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<T>)
#ifdef _DEBUG

View file

@ -480,7 +480,7 @@ int InVector<T>::Find(const T& val, const L& less)
template <class T>
void InVector<T>::SetIter(ConstIterator& it, int ii)
void InVector<T>::SetIter(ConstIterator& it, int ii) const
{
if(count) {
it.v = this;
@ -494,7 +494,7 @@ void InVector<T>::SetIter(ConstIterator& it, int ii)
}
template <class T>
void InVector<T>::SetBegin(ConstIterator& it)
void InVector<T>::SetBegin(ConstIterator& it) const
{
if(count) {
it.v = this;
@ -508,7 +508,7 @@ void InVector<T>::SetBegin(ConstIterator& it)
}
template <class T>
void InVector<T>::SetEnd(ConstIterator& it)
void InVector<T>::SetEnd(ConstIterator& it) const
{
if(count) {
it.v = this;
@ -557,6 +557,18 @@ void InVector<T>::ConstIterator::PrevBlk()
offset -= v->data[blki].GetCount();
}
template <typename T>
void InVector<T>::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 <class T>
void InVector<T>::DumpIndex()