本文整理汇总了C++中BaseArray::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseArray::Resize方法的具体用法?C++ BaseArray::Resize怎么用?C++ BaseArray::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseArray
的用法示例。
在下文中一共展示了BaseArray::Resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// This function demonstrates the basic methods of our arrays and lists.
// To keep it simple it does not check for errors. For real-life code
// you have to check the return value of Append() or Insert() before you
// access the memory.
static void BaseArrayDemo()
{
BaseArray<VLONG> test; // this could be BlockArray, PointerArray, SortedArray or BaseList
VLONG copyMe = 42;
VLONG i;
test.Append(); // append an element with default value
test.Append(copyMe); // append a copy of copyMe
test.Insert(1); // insert an element with default value at index 1
test.Insert(2, copyMe); // insert a copy of copyMe at index 2
test.Erase(0); // erase element at index 0
test[2] = 12345; // assign a value to the element at index 2
// iterate over all elements, assign value
for (i = 0; i < test.GetCount(); i++)
test[i] = i;
test.Resize(27); // the array has now 27 elements
test.Erase(10, 15); // erase 15 elements from index 10 on
test.Append(9876);
test.Append(54321);
// iterate over all elements, check for some value
for (AutoIterator<BaseArray<VLONG> > it(test); it; ++it)
{
if (*it == 9876)
break; // BTW: the index of this element is it - test.Begin();
}
}