// llist.cpp: implementation of the llist class.
//
//////////////////////////////////////////////////////////////////////
#include "llist.h"
#include "link.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
bool llist::insert(const double& item)
{
fence->next=new link(item,fence->next);
if(tail==fence)tail=fence->next;
rightcnt++;
return true;
}
bool llist::append(const double &item)
{
tail=tail->next=new link(item,NULL);
rightcnt++;
return true;
}
bool llist::remove(double &it)
{
if(fence->next==NULL)return false;
it=fence->next->element;
link* itemp=fence->next;
fence->next=itemp->next;
if(tail==itemp)tail=fence;
delete itemp;
rightcnt++;
return true;
}
void llist::prev()
{
link *temp=head;
if(fence==head)return;
while(temp->next!=fence)temp=temp->next;
fence=temp;
leftcnt--;rightcnt++;
}
bool llist::setpos(int pos)
{
if((pos<0)||(pos>rightcnt+leftcnt))return false;
fence=head;
for(int i=0;i<pos;i++)
fence=fence->next;
return true;
}
void llist::print() const
{
link* temp=head;
cout<<"< ";
while(temp->next!=NULL)
{
cout<<temp->next->element<<" ";
temp=temp->next;
}
cout<<" >\n";
}
bool llist::exchange()
{
link* first;
link* mid;
link* last;
link* temp;
int Temp;
first=NULL;
last=head->next;
mid=head;
while(last!=NULL)
{
mid->next=first;
first=mid;
mid=last;
last=last->next;
}
mid->next=first;
temp=head;
head=tail;
tail=temp;
Temp=leftcnt;
leftcnt=rightcnt;
rightcnt=Temp;
temp=new link;
temp->next=head;
head=temp;
setend();
prev();
delete fence->next;
fence->next=NULL;
tail=fence;
return true;
}
用VC编写单链表(数据结构).rar_VC 链表_单链表_数据结构 链表_链表
版权申诉
141 浏览量
2022-09-21
03:31:47
上传
评论
收藏 11KB RAR 举报
小贝德罗
- 粉丝: 69
- 资源: 1万+
最新资源
- 笔记实验六,spark,大数据分析
- ####蓝桥杯python的详细的信息介绍
- 电子万年历软件仿真(经过多次修改,保证正确性)
- Unity XR 手势射击控制脚本(适用于任何可手势识别的设备)
- 机械设计全自动电表(NB和IC卡表)控制和上壳装配线sw16可编辑非常好的设计图纸100%好用.zip
- 基于matlab的EAN-13条形码识别系统GUI界面.zip代码53
- matlab基于bp神经网络交通信号标志识别GUI界面13个标志.zip代码54
- 电子万年历答辩实物展示视频mp4格式
- 基于python实现的程序,包括哈希感知算法cvHash,图像切割cvsplit,固定目标检测cvRec(附文档ppt)等
- 计算0-10000之间所有偶数的和
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0