⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 karray.h

📁 一个简单而又高效的嵌入式操作系统.包括GUI及文件系统.仿Windows设计,类似于MFC风格
💻 H
字号:
// KArray.h: interface for the KArray class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_KARRAY_H__F19FEDC1_6BDB_46F8_889C_1C0688F0AD0E__INCLUDED_)
#define AFX_KARRAY_H__F19FEDC1_6BDB_46F8_889C_1C0688F0AD0E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// KArray<TYPE>

template<class TYPE>
class KArray
{
public:
// Construction
	KArray();

// Attributes
	int GetSize() const;
	void SetSize(int nNewSize, int nGrowBy);

// Operations
	// Clean up
	void FreeExtra();
	void RemoveAll();

	// Accessing elements
	TYPE GetAt(int nIndex) const;
	void SetAt(int nIndex, TYPE newElement);
	TYPE& ElementAt(int nIndex);

	// Direct Access to the element data (may return NULL)
	const TYPE* GetData() const;
	TYPE* GetData();

	// Potentially growing the array
	void SetAtGrow(int nIndex, TYPE newElement);
	int Add(TYPE newElement);
	int Append(const KArray& src);
	void Copy(const KArray& src);

	// overloaded operator helpers
	TYPE operator[](int nIndex) const;
	TYPE& operator[](int nIndex);

	// Operations that move elements around
	void InsertAt(int nIndex, TYPE newElement, int nCount);
	void RemoveAt(int nIndex, int nCount);
	void InsertAt(int nStartIndex, KArray* pNewArray);
	void InsertAt(int nIndex, TYPE newElement);
	void RemoveAt(int nIndex);

// Implementation
protected:
	TYPE* m_pData;   // the actual array of data
	int m_nSize;     // # of elements (upperBound - 1)
	int m_nMaxSize;  // max allocated
	int m_nGrowBy;   // grow amount

public:
	~KArray();
};

#endif // !defined(AFX_KARRAY_H__F19FEDC1_6BDB_46F8_889C_1C0688F0AD0E__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -