*Core: Fixed Vector::InsertSplit

git-svn-id: svn://ultimatepp.org/upp/trunk@5800 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-02-12 20:41:41 +00:00
parent c84ae833b6
commit bb9068f7e0
2 changed files with 11 additions and 1 deletions

View file

@ -1,9 +1,15 @@
template <class K, class T, class Less = StdLess<K> >
class SortedVectorMap;
template <class T>
class InVector : public MoveableAndDeepCopyOption< InVector<T> > {
public:
class ConstIterator;
class Iterator;
template <class K, class V, class L> friend class SortedVectorMap;
private:
Vector< Vector<T> > data;
Vector< Vector<int> > index;
@ -229,6 +235,8 @@ private:
ALess(const L& less) : less(less) {}
};
template <class K, class V, class L> friend class SortedVectorMap;
public:
T& Insert(int i, T *newt) { iv.Insert(i, newt); return *newt; }
T& Insert(int i) { return Insert(i, new T); }
@ -380,6 +388,8 @@ template <class T, class Less = StdLess<T> >
class SortedIndex : MoveableAndDeepCopyOption< SortedIndex<T, Less> > {
InVector<T> iv;
Less less;
template <class K, class V, class L> friend class SortedVectorMap;
public:
int Add(const T& x) { return iv.InsertUpperBound(x, less); }

View file

@ -318,8 +318,8 @@ void Vector<T>::InsertSplit(int i, Vector<T>& v, int from)
if(n) {
RawInsert(i, n);
memcpy(vector + i, v.vector + from, sizeof(T) * n);
v.items = from;
}
v.Trim(from);
}
template <class T>