/** Move attached rows to somewhere else in same storage * * There is a lot of trickery going on here. The whole point of this * code is that moving rows between (compatible!) subviews should not * use copying when potentially large memo's and subviews are involved. * In that case, the best solution is really to move pointers, not data. */ void c4_View::RelocateRows(int from_, int count_, c4_View& dest_, int pos_) { if (count_ < 0) count_ = GetSize() - from_; if (pos_ < 0) pos_ = dest_.GetSize(); d4_assert(0 <= from_ && from_ <= GetSize()); d4_assert(0 <= count_ && from_ + count_ <= GetSize()); d4_assert(0 <= pos_ && pos_ <= dest_.GetSize()); if (count_ > 0) { // the destination must not be inside the source rows d4_assert(&dest_ != this || from_ > pos_ || pos_ >= from_ + count_); // this test is slow, so do it only as a debug check d4_assert(IsCompatibleWith(dest_)); // make space, swap rows, drop originals c4_Row empty; dest_.InsertAt(pos_, empty, count_); // careful if insert moves origin if (&dest_ == this && pos_ <= from_) from_ += count_; for (int i = 0; i < count_; ++i) ((c4_HandlerSeq*) _seq)->ExchangeEntries(from_ + i, *(c4_HandlerSeq*) dest_._seq, pos_ + i); RemoveAt(from_, count_); } }
bool c4_SliceViewer::InsertRows(int pos_, c4_Cursor value_, int count_) { if (_step != 1) return false; pos_ = _first + _step *(_step > 0 ? pos_ : pos_ - GetSize() + 1); if (_limit >= 0) _limit += count_; _parent.InsertAt(pos_, *value_, count_); return true; }
int CResizer::Ins(int pos_, int cnt_) { A(pos_ <= _refSize); A(_refSize + cnt_ < kMaxData); memmove(_refData + pos_ + cnt_, _refData + pos_, _refSize - pos_); _refSize += cnt_; c4_Row row; _unattached.InsertAt(pos_, row, cnt_); _attached.InsertAt(pos_, row, cnt_); for (int i = pos_; i < pos_ + cnt_; ++i) { _refData[i] = ++_seed; _prop(_unattached[i]) = _seed; _prop(_attached[i]) = _seed; if (_seed >= 123) _seed = 0; } Verify(); return _refSize; }
bool c4_PairViewer::InsertRows(int pos_, c4_Cursor value_, int count_) { _parent.InsertAt(pos_, *value_, count_); _argView.InsertAt(pos_, *value_, count_); return true; }