//循环单链表
//定义
typedef struct LNode{
int data;
LNode *next;
}LNode,*LinkList;
//初始化
bool InitList(LinkList &L){
L=new LNode;
if(L==null)return false;
L->next=L;
return true;
}
//空表
bool Empty(LinkList &L){
if(L->next==L)return true;
else return false;
}
// 点p是否为循环单链表的表尾节点
bool isTail(LinkList &L,LNode *p){
if(p->next==L)return true;
else return false;
}
//循环双链表
//定义
typedef struct DLNode(DLinkList &L){
int data;
DLNode *prior;
DLNode *next;
}DLNode,*DLinkList;
//初始化
bool DinitList(LinkList &L){
L=new DLNode;
if(L==null)return false;
L->next=L;
L->prior=L;
return true;
}
//判空
bool empty(LinkList &L){
if(L->next==L)return true;
else return false;
}
//点p是否为循环双链表的表尾节点
bool isTail(DLinkList &L,DNode *p){
if(p->next==L)return true;
else return false;
}
循环链表的基本操作
最新推荐文章于 2024-06-21 00:00:00 发布