本文整理汇总了C++中c4_DWordArray::InsertAt方法的典型用法代码示例。如果您正苦于以下问题:C++ c4_DWordArray::InsertAt方法的具体用法?C++ c4_DWordArray::InsertAt怎么用?C++ c4_DWordArray::InsertAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c4_DWordArray
的用法示例。
在下文中一共展示了c4_DWordArray::InsertAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: iter
void c4_FormatB::Insert(int index_, const c4_Bytes& buf_, int count_)
{
d4_assert(count_ > 0);
_recalc = true;
int m = buf_.Size();
t4_i32 off = Offset(index_);
_memos.InsertAt(index_, 0, count_);
// insert the appropriate number of bytes
t4_i32 n = count_ * (t4_i32) m;
if (n > 0) {
_data.Grow(off, n);
// store as many copies as needed, but may have to do it in chunks
int spos = 0;
c4_ColIter iter (_data, off, off + n);
while (iter.Next(m - spos)) {
memcpy(iter.BufSave(), buf_.Contents() + spos, iter.BufLen());
spos += iter.BufLen();
if (spos >= m)
spos = 0;
}
d4_assert(spos == 0); // must have copied an exact multiple of the data
}
// define offsets of the new entries
_offsets.InsertAt(index_, 0, count_);
d4_assert(_offsets.GetSize() <= _memos.GetSize() + 1);
while (--count_ >= 0) {
_offsets.SetAt(index_++, off);
off += m;
}
d4_assert(index_ < _offsets.GetSize());
// adjust all following entries
while (index_ < _offsets.GetSize())
_offsets.ElementAt(index_++) += n;
d4_assert((t4_i32) _offsets.GetAt(index_ - 1) == _data.ColSize());
d4_assert(index_ <= _memos.GetSize() + 1);
}
示例2: buf_
void c4_FormatB::SetOne(int index_, const c4_Bytes &xbuf_, bool ignoreMemos_) {
// this fixes bug in 2.4.0 when copying string from higher row
// TODO: this fix is very conservative, figure out when to copy
// (can probably look at pointer to see whether it's from us)
int sz = xbuf_.Size();
c4_Bytes buf_(xbuf_.Contents(), sz, 0 < sz && sz <= c4_Column::kSegMax);
c4_Column *cp = &_data;
t4_i32 start = Offset(index_);
int len = Offset(index_ + 1) - start;
if (!ignoreMemos_ && _memos.GetAt(index_) != 0)
len = ItemLenOffCol(index_, start, cp);
int m = buf_.Size();
int n = m - len;
if (n > 0)
cp->Grow(start, n);
else if (n < 0)
cp->Shrink(start, - n);
else if (m == 0)
return ;
// no size change and no contents
_recalc = true;
cp->StoreBytes(start, buf_);
if (n && cp == &_data) {
// if size has changed
int k = _offsets.GetSize() - 1;
// if filling in an empty entry at end: extend offsets first
if (m > 0 && index_ >= k) {
_offsets.InsertAt(k, _offsets.GetAt(k), index_ - k + 1);
k = index_ + 1;
d4_assert(k == _offsets.GetSize() - 1);
}
// adjust following entry offsets
while (++index_ <= k)
_offsets.ElementAt(index_) += n;
}
d4_assert((t4_i32)_offsets.GetAt(_offsets.GetSize() - 1) == _data.ColSize());
}