LinearList.zip
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
线性表C++语言实现,包含《数据结构算法与应用-C++语言描述》练习题。 template<class T> class LinearList { public: LinearList(int MaxListSize = 10);//构造函数 LinearList(LinearList<T>& L);//复制构造函数 ~LinearList() { delete[] element; }//析构函数 bool IsEmpty() const { return length == 0; }//判断线性表是否为空 int Length() const { return length; }//返回数组长度 void SetLength(int SetLength) { length = SetLength; }//设置数组长度 int MaxSize_ret() const { return MaxSize; }//返回数组最大长度 int Current_ret(void) const { return current; } bool Find(int k, T& x);//返回第k个元素至x中 int Search(const T& x) const;//返回x所在位置 LinearList<T>& Delete(int k, T& x);//删除第k个元素并将它返回至x中 LinearList<T>& Insert(int k, const T& x);//在第k个元素之后插入x LinearList<T>& Insert(const T& x);//在表尾插入x void Output(ostream& out) const; void Self_adaption_LinearList_Size(void); void Reverse(void); bool Half(void); LinearList<T>& Alternate(LinearList<T>& A, LinearList<T>& B); LinearList<T>& Merge(LinearList<T>& A, LinearList<T>& B); LinearList<T>& Merge_1(LinearList<T>& A, LinearList<T>& B); void Split(LinearList<T>& A, LinearList<T>& B); LinearList<T>& Sort(void); /*关于前移和后移*/ void Reset(void) { current = 1; } //置current为0 T Current(void) { return element[current-1]; }//返回当前元素 bool End(void);//当且仅当当前元素为表的最后一个元素时,返回true bool Front(void);//当且仅当当前元素为表的第一个元素时,返回true void Next(void);//移动current至表中的下一个元素,如果操作失败则引发一个异常 void Previous(void);//移动current至表中的前一个元素,如果操作失败则引发一个异常 private: int length;//线性表长度 int MaxSize;//线性表最大可容纳的长度 int current;//记录线性表当前的位置 T* element;//一维动态数组 };
- 1
- Petrichor8522022-07-20资源很实用,对我启发很大,有很好的参考价值,内容详细。
- hanpeng123992022-09-05感谢资源主分享的资源解决了我当下的问题,非常有用的资源。
- 粉丝: 1w+
- 资源: 12
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助