包含于MFC的头文件为 #include <afxtempl.h>
缺点:只能适用于MFC,有一个巨大的缺点就是速度慢,大规模运算会造成较大的延时,在实时性要求比较高的场合是不适用的。相比较之下,用std::vector效率可能会更好
class CArray : public CObject
{
INT_PTR GetSize() const; //获取数组的大小
INT_PTR GetCount() const; //获取元素个数(有时候和GetSize()一样)
BOOL IsEmpty() const; //是否为空
INT_PTR GetUpperBound() const;
void SetSize(INT_PTR nNewSize, INT_PTR nGrowBy = -1); //设置数组的大小
// Operations
void RemoveAll(); //移除所有对象
// Accessing elements
const TYPE& GetAt(INT_PTR nIndex) const; //根据指定的下标获取元素
void SetAt(INT_PTR nIndex, ARG_TYPE newElement);//设置指定下标的元素
INT_PTR Add(ARG_TYPE newElement); //增加元素
INT_PTR Append(const CArray& src); //把另外一个数组增加到数组中
void Copy(const CArray& src); //复制另外一个数组到数组中
// overloaded operator helpers
const TYPE& operator[](INT_PTR nIndex) const;//等同于GetAt(index)功能
// Operations that move elements around
void InsertAt(INT_PTR nIndex, ARG_TYPE newElement, INT_PTR nCount = 1);
void RemoveAt(INT_PTR nIndex, INT_PTR nCount = 1);
//移除指定指针的元素(后面元素上移)
void InsertAt(INT_PTR nStartIndex, CArray* pNewArray);
};
文章评论
共有 0位网友发表了评论 我来说两句