#include <iostream>
using namespace std;
template<class T>
class SeqList
{
public:
SeqList(int size=64);
SeqList(T value[],int n);
~SeqList();
bool isEmpty();
int length();
T get(int i);
bool set(int i,T x);
friend ostream &operator<<<T>(ostream &out,SeqList<T> &list);
void insert(int i,T x);
void insert(T x);
bool remove(int i,T &old);
void clear();
private:
T *element;
int size;
int len;
};
template<class T>
SeqList<T>::SeqList(int size)
{
this->size=size<64?64:size;
this->element=new T[this->size];
this->len=0;
}
template<class T>
SeqList<T>::SeqList(T value[],int n)
{
if (n>0)
{
this->element=new T[2*n];
this->size=2*n;
this->len=n;
for(int i=0;i <n;i ++)
{
this->element[i]=value[i];
}
}
}
template<class T>
SeqList<T>::~SeqList()
{
delete []this->e
约瑟夫环-顺序表-C++
最新推荐文章于 2022-01-06 13:47:59 发布