// 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(); } }