แก้ไข

แชร์ผ่าน


CByteArray Class

Supports dynamic arrays of bytes.

Syntax

class CByteArray : public CObject

Members

The member functions of CByteArray 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 BYTE.

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

for example, translates to

BYTE CByteArray::GetAt( int <nIndex> ) const;

Public Constructors

Name Description
CByteArray::CByteArray Constructs an empty array.

Public Methods

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

Public Operators

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

Remarks

CByteArray incorporates the IMPLEMENT_SERIAL macro to support serialization and dumping of its elements. If an array of bytes is stored to an archive, either with the overloaded insertion ( <<) operator or with the 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 debug output from individual elements in the array, you must set the depth of the CDumpContext object to 1 or greater.

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

Inheritance Hierarchy

CObject

CByteArray

Requirements

Header: afxcoll.h

See also

CObject Class
Hierarchy Chart
CObArray Class