本文整理汇总了C++中QArray::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ QArray::reserve方法的具体用法?C++ QArray::reserve怎么用?C++ QArray::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QArray
的用法示例。
在下文中一共展示了QArray::reserve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void QGLIndexBufferPrivate::append
(const QGLIndexBufferPrivate *other, uint offset, int start)
{
if (elementType == GL_UNSIGNED_SHORT &&
other->elementType == GL_UNSIGNED_SHORT) {
// Both buffers are ushort.
const ushort *data = other->indexesShort.constData() + start;
int count = other->indexesShort.count() - start;
indexesShort.reserve(indexesShort.count() + count);
indexCount += count;
while (count-- > 0)
indexesShort.append(ushort(*data++ + offset));
} else if (elementType == GL_UNSIGNED_SHORT) {
// Only first buffer is ushort: convert it to int first.
const ushort *indexes = indexesShort.constData();
int count = indexesShort.count();
indexesInt.reserve(count + other->indexesInt.count());
while (count-- > 0)
indexesInt.append(*indexes++);
indexesShort = QArray<ushort>();
elementType = GL_UNSIGNED_INT;
const uint *data = other->indexesInt.constData() + start;
count = other->indexesInt.count() - start;
indexCount += count;
while (count-- > 0)
indexesInt.append(*data++ + offset);
} else if (other->elementType == GL_UNSIGNED_SHORT) {
// Only second buffer is ushort.
const ushort *data = other->indexesShort.constData() + start;
int count = other->indexesShort.count() - start;
indexesInt.reserve(indexesInt.count() + count);
indexCount += count;
while (count-- > 0)
indexesInt.append(*data++ + offset);
} else {
// Neither buffer is ushort.
const uint *data = other->indexesInt.constData() + start;
int count = other->indexesInt.count() - start;
indexesInt.reserve(indexesInt.count() + count);
indexCount += count;
while (count-- > 0)
indexesInt.append(*data++ + offset);
}
}