📄 group.h
字号:
// Group.h: interface for the CGroup class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GROUP_H__D6A5CF62_1D47_42F5_B4FD_526870E658F0__INCLUDED_)
#define AFX_GROUP_H__D6A5CF62_1D47_42F5_B4FD_526870E658F0__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
template<class TYPE>
class CGroup
{
public:
int m_nCount;
TYPE* m_pData;
public:
void Init(int nCount);
void Clear();
TYPE GetAt(int nIndex);
void SetAt(int nIndex,TYPE value);
int GetSize();
public:
TYPE& operator [](int nIndex);
public:
CGroup();
CGroup(int nCount);
virtual ~CGroup();
};
template<class TYPE>
CGroup<TYPE>::CGroup()
{
m_nCount = 0;
m_pData = NULL;
}
template<class TYPE>
CGroup<TYPE>::CGroup(int nCount)
{
m_nCount = 0;
m_pData = NULL;
Init(nCount);
}
template<class TYPE>
CGroup<TYPE>::~CGroup()
{
Clear();
}
template<class TYPE>
void CGroup<TYPE>::Clear()
{
if (m_pData != NULL)
delete[] m_pData;
m_pData = NULL;
m_nCount = 0;
}
template<class TYPE>
void CGroup<TYPE>::Init(int nCount)
{
if (nCount < 1)
return;
Clear();
m_pData = new TYPE[nCount];
m_nCount = nCount;
}
template<class TYPE>
TYPE CGroup<TYPE>::GetAt (int nIndex)
{
return m_pData[nIndex];
}
template<class TYPE>
void CGroup<TYPE>::SetAt (int nIndex,TYPE value)
{
m_pData[nIndex] = value;
}
template<class TYPE>
TYPE& CGroup<TYPE>::operator [] (int nIndex)
{
return m_pData[nIndex];
}
template<class TYPE>
int CGroup<TYPE>::GetSize()
{
return m_nCount;
}
typedef CGroup<int> CIntGroup;
typedef CGroup<float> CFloatGroup;
typedef CGroup<DWORD> CDwordGroup;
typedef CGroup<double> CDoubleGroup;
;
#endif // !defined(AFX_GROUP_H__D6A5CF62_1D47_42F5_B4FD_526870E658F0__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -