Muokkaa

Jaa


CWordArray Class

Supports arrays of 16-bit words.

Syntax

class CWordArray : public CObject

Members

The member functions of CWordArray are similar to the member functions of class CObArray. Because of this similarity, you can use the CObArray reference documentation for member function specifics. Wherever you see a CObject pointer as a function parameter or return value, substitute a WORD.

CObject* CObArray::GetAt( int <nIndex> ) const;

for example, translates to

WORD CWordArray::GetAt( int <nIndex> ) const;

Public Constructors

Name Description
CWordArray::CWordArray Constructs an empty array.

Public Methods

Name Description
CWordArray::Add Adds an element to the end of the array; grows the array if necessary.
CWordArray::Append Appends another array to the array; grows the array if necessary.
CWordArray::Copy Copies another array to the array; grows the array if necessary.
CWordArray::ElementAt Returns a temporary reference to the element pointer within the array.
CWordArray::FreeExtra Frees all unused memory above the current upper bound.
CWordArray::GetAt Returns the value at a given index.
CWordArray::GetCount Gets the number of elements in this array.
CWordArray::GetData Allows access to elements in the array. Can be NULL.
CWordArray::GetSize Gets the number of elements in this array.
CWordArray::GetUpperBound Returns the largest valid index.
CWordArray::InsertAt Inserts an element (or all the elements in another array) at a specified index.
CWordArray::IsEmpty Determines if the array is empty.
CWordArray::RemoveAll Removes all the elements from this array.
CWordArray::RemoveAt Removes an element at a specific index.
CWordArray::SetAt Sets the value for a given index; array not allowed to grow.
CWordArray::SetAtGrow Sets the value for a given index; grows the array if necessary.
CWordArray::SetSize Sets the number of elements to be contained in this array.

Public Operators

Name Description
CWordArray::operator[] Sets or gets the element at the specified index.

Remarks

CWordArray incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. If an array of words is stored to an archive, either with an overloaded insertion operator or with the CObject::Serialize member function, each element is, in turn, serialized.

Note

Before using an array, use SetSize to establish its size and allocate memory for it. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory.

If you need a dump of individual elements in the array, you must set the depth of the dump context to 1 or greater.

For more information on using CWordArray, see the article Collections.

Inheritance Hierarchy

CObject

CWordArray

Requirements

Header: afxcoll.h

See also

MFC Sample COLLECT
CObject Class
Hierarchy Chart