How to Use Dynamic Arrays
- How to use dynamic arrays
This document describes how to create templated arrays; that is, an array of a particular type of object.
- How to append and insert elements
Elements can be added into an array or added to the end by specifying the insertion position.
- How to remove elements
It is possible to remove one or several contiguous elements from any array. Deleting elements from an array may not automatically free up memory.
- How to expand the array
An array can be expanded by using the ExpandL() function.
- How to reserve space in a fixed flat array
To be sure that there is sufficient space available to add new elements to a fixed flat array, you can use the SetReserveL() function to pre-allocate memory.
- How to resize an array
For fixed flat and fixed segmented arrays, it is possible to resize the array. If the array is shortened, then the trailing elements are deleted. If the array is extended, then new blank elements are created using the default constructor.
- How to find elements
There are two methods for searching for data in an array. Sequentially and binary chop.
- How to access elements
The elements of an array can be accessed by specifying the position of the element in the array.
- How to destroy the array
Simple arrays can be simply deleted. Certain arrays of pointers may require calling a member function to delete the objects pointed to.
- How to create a generic array
Arrays can be created using a templated class. This allows a degree of polymorphism to be used without needing to know the data type in the array.
- Pointers to the start and end of contiguous regions
The Back() and End() functions point to locations in memory for flat and segmented arrays.
- Using CArrayFixFlat<TAny>
The CArrayFixFlat<Tany> class is useful for constructing an array of fixed length buffers, where the length is decided at run time.
- Using CArrayFixSeg<TAny>
The CArrayFixSeg<TAny> is useful for constructing an array of fixed length buffers, where the length is decided at run time.
- Using CArrayPak<TAny>
The class is useful for constructing an array of variable length buffers, where the length is decided at run time.
- Using CArrayVar<TAny>
The CArrayVar<TAny> class is useful for constructing an array of variable length buffers, where the length is decided at run time.
- Using RArray<class T>
This document covers the important issues involved in using an RArray.
- Using RPointerArray<class T>
This document covers the issues involved in using a RPointerArray.
- Using TArray<class T>
This document covers important issues in using TArray
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.