不带头节点的单链表的实现完成Do not take the lead singlelinked list of nodes to complete
#包括< iostream。 ”
模板<
课堂环节
{
公共
T数据
链接下一个
链接const T信息链接<T> * nextvalue = null {
数据=信息
未来= nextvalue
}
链接const环节<T> * nextvalue = null {
未来= nextvalue
}
}
模板<
类lnklist
{
私人
链接* *头 *尾
链接<T> * SETPOS const int p
公共lnklist
~ lnklist
布尔是空的 //检查链表是否为空
清空 //将链表存储的内容清除成为空表
空白打印 int length //返回此链表的当前实际长度
布尔加const T值 / /在表尾添加一个元素价值表的长度增1插入const int p const T值 / /在位置P上插入一个元素价
值表的长度增1
为消除const int p //删除位置P上的元素表的长度减1布尔getValue const int p t值 / /返回位置P的元素值布尔率int & P const T值 / /查找值为价值的元素并返回第1次出现的位置
}
模板<
链接<T> * lnklist <T> SETPOS int i
{int计数= 0
链接
而P = null &计算< i
{
下一页
计数+
}
返回p
}
模板<lnklist <T> lnklist {头=尾=空
}
模板<lnklist <T> ~ lnklist {链接< * * TMP
当头 = NULL {
头=下一个
删除T MP
}
}
模板<
无效lnklist <T> print {
链接
而P = null
{cout << P ->数据<<”
下一页
}
}
模板<
布尔lnklist <T> 是空的 {如果头= NULL
返回true
}
模板<
无效lnklist <T> 明确{
链接< * =头 * T MP
而P = null
{
T MP = P
下一页
删除T MP
}
}
模板<
国际lnklist <T> 长度 {int计数= 0
链接
而P = NULL {
下一页
计数+
}
返回计数
}
模板<
布尔lnklist <T> 附加const T值{
链接< * > *
新建链接<值>zero) ;if (head = = null)head = tail = p;else
{tail - > next = p;
tail = p;
}return true;
}class template < t >bool lnklist < t >: : insert (const int i, const t value) {link < t > * p * q;if (i = = 0) {d = new link < t > (value, head) .head = q;if (tail = = null)tail = q;return true;
}if ( (p = setpos (i - 1) = = 0) {court < < "insertion point is illegal" < < endl;
return false;
}d = new link < t > (value, p - > next) .p - > next = q;if (p = = tail) and tail = q;return true;
}class template < t >bool lnklist < t >: : remove (const int i){link < t > * p * q;if (head = = 0) {court < < "no element to delete" < < endl;return false;
}
CUBECLOUD(魔方云)成立于2016年,亚太互联网络信息中心(APNIC)会员,全线产品均为完全自营,专业数据灾备冗余,全部产品均为SSD阵列,精品网络CN2(GIA) CU(10099VIP)接入,与当今主流云计算解决方案保持同步,为企业以及开发者用户实现灵活弹性自动化的基础设施。【夏日特促】全场产品88折优惠码:Summer_2021时间:2021年8月1日 — 2021年8月8日香港C...
丽萨主机怎么样?丽萨主机,团队于2017年成立。成立之初主要做的是 CDN 和域名等相关业务。最近开辟新领域,新增了独立服务器出租、VPS 等业务,为了保证业务质量从一开始就选择了中美之间的 CN2 GIA 国际精品网络,三网回程 CN2 GIA,电信去程 CN2 GIA + BGP 直连智能路由,联通移动去程直连,原生IP。适合对网络要求较高的用户,同时价格也比较亲民。点击进入:丽萨主机官方网站...
近日Friendhosting发布了最新的消息,新上线了美国迈阿密的云产品,之前的夏季优惠活动还在进行中,全场一次性45折优惠,最高可购买半年,超过半年优惠力度就不高了,Friendhosting商家的优势就是100Mbps带宽不限流量,有需要的朋友可以尝试一下。Friendhosting怎么样?Friendhosting服务器好不好?Friendhosting服务器值不值得购买?Friendho...