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

📄 simchain.h

📁 模拟指针,使用固定的数组模拟指针的内存分配
💻 H
字号:
#ifndef _SIMCHAIN_H
#define _SIMCHAIN_H

#include <iostream>
using namespace std;

template <typename T> class CSimSpace;
template <typename T> class CSimChain;


template <typename T>
class CSimNode
{
	friend class CSimSpace<T>;
	friend class CSimChain<T>;

	T data;
	int link;
};

template<typename T>
class CSimSpace
{
	friend class CSimChain<T>;
public:
	CSimSpace(int MaxSpaceSize=100);
	~CSimSpace();
	int Allocate();
	void DeAllocate(int &i);
private:
	int NumberOfNode;
	int first;
	CSimNode<T> *node;
};


template<typename T>
class CSimChain
{
public:
	CSimChain(){first=-1;}
	~CSimChain(){Destroy();}
	void FillElem(T temp[],int len);
	void Destroy();
	int  Length() const;
	bool Find(int k,T &x) const;
	int  Search(const T&x) const;
	CSimChain<T>& Delete(int k,T &x);
	CSimChain<T>& Insert(int k,const T &x);
	void Output(ostream &out)const;
private:
	int first;
	static CSimSpace<T> S;
};



#endif

⌨️ 快捷键说明

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