线性表作为一种线性数据结构,常应用于信息检索,存储管理等诸多领域,因此了解线性表的基本操作与应用对于我们学习数据结构有着十分重要的意义。

一,线性表的基本操作

首先,我们定义一个线性表的基类linearlist,并以此定义了它的派生类顺序表类seqlist和链表类singlelist.在基类中,我们以抽象函数的形式定义了线性表常用的几种操作,如插入删除等。

#ifndef LINEARLIST_H_INCLUDED
#define LINEARLIST_H_INCLUDED
#include<iostream>
using namespace std;
template<class T>
class Linearlist
{
public:
    virtual bool IsEmpty() const=0;
    virtual int Length()const=0;
    virtual bool Find(int i,T&x)const=0;
    virtual  int Search(T x)const=0;
    virtual bool Insert(int i,T x)=0;
    virtual bool Delete(int i)=0;
    virtual bool Update(int i,T x)=0;
    virtual void Output(ostream& out)const=0;
protected:
    int n;
};
#endif // LINEARLIST_H_INCLUDED
View Code

相关文章:

  • 2022-12-23
  • 2021-07-06
  • 2021-09-07
  • 2021-10-11
  • 2021-10-18
  • 2022-12-23
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2022-03-08
  • 2021-12-29
  • 2022-12-23
相关资源
相似解决方案