C++ 静态链表基本算法实现
#ifndef StaticLinkList_h#define StaticLinkList_hconst int MAXSIZE = 100;templatestruct StaticNode{ T data; int next;};template class StaticLinkList{public: StaticLinkList(); StaticLinkList(T a[], int n); void Insert(int i, T a); T Delete(int i); int Get(int n); int Locate(T x); int NewNode(); void DeleteNode(int i);private: int front; int tail; StaticNode SArray[MAXSIZE];}template StaticLinkList :: StaticLinkList(){ for(int i = 0;i StaticLinkList :: StaticLinkList(T a[], int n){ if(n>MAXSIZE) throw "溢出"; for(int i=0;i int StaticLinkList ::NewNode(){ if(-1 == tail) throw"空间不足"; int pos = tail; tail = SArray[tail].next; return pos;}template T StaticLinkList ::Delete(int i){ if(i<0 || i>MAXSIZE -1){ throw "释放空间错误";} if(front == i) front = SArray[i].next; SArray[i].next = tail; tail = i;}#endif /* StaticLinkList_h */