Share via


CSimpleArray Class

This class provides methods for managing a simple array.

template < 
   class T, 
   class TEqual = CSimpleArrayEqualHelper< T > 
>  
class CSimpleArray

Parameters

  • T
    The type of data to store in the array.

  • TEqual
    A trait object, defining the equality test for elements of type T.

Members

Public Constructors

Name

Description

CSimpleArray::CSimpleArray

The constructor for the simple array.

CSimpleArray::~CSimpleArray

The destructor for the simple array.

Public Methods

Name

Description

CSimpleArray::Add

Adds a new element to the array.

CSimpleArray::Find

Finds an element in the array.

CSimpleArray::GetData

Returns a pointer to the data stored in the array.

CSimpleArray::GetSize

Returns the number of elements stored in the array.

CSimpleArray::Remove

Removes a given element from the array.

CSimpleArray::RemoveAll

Removes all elements from the array.

CSimpleArray::RemoveAt

Removes the specified element from the array.

CSimpleArray::SetAtIndex

Sets the specified element in the array.

Public Operators

Name

Description

CSimpleArray::operator []

Retrieves an element from the array.

CSimpleArray::operator =

Assignment operator.

Remarks

CSimpleArray provides methods for creating and managing a simple array, of any given type T.

The parameter TEqual provides a means of defining an equality function for two elements of type T. By creating a class similar to CSimpleArrayEqualHelper, it is possible to alter the behavior of the equality test for any given array. For example, when dealing with an array of pointers, it may be useful to define the equality as depending on the values the pointers reference. The default implementation utilizes operator=().

Both CSimpleArray and CSimpleMap are designed for a small number of elements. CAtlArray and CAtlMap should be used when the array contains a large number of elements.

Requirements

Header: atlsimpcoll.h

Example

// Create an array of integers
CSimpleArray<int> iArray;

// Create an array of char pointers 
// and use a new equality function
CSimpleArray<char *, MyEqualityEqualHelper<char *> > cMyArray;   

See Also

Other Resources

ATL Class Overview