不带头节点的单链表的实现完成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;
}
每年的7月的最后一个周五是全球性质的“系统管理员日”,据说是为了感谢系统管理员的辛苦工作....friendhosting决定从现在开始一直到9月8日对其全球9个数据中心的VPS进行4.5折(优惠55%)大促销。所有VPS基于KVM虚拟,给100M带宽,不限制流量,允许自定义上传ISO...官方网站:https://friendhosting.net比特币、信用卡、PayPal、支付宝、微信、we...
LOCVPS发来了针对XEN架构VPS的促销方案,其中美国洛杉矶机房7折,其余日本/新加坡/中国香港等机房全部8折,优惠后日本/新加坡机房XEN VPS月付仅29.6元起。这是成立较久的一家国人VPS服务商,目前提供美国洛杉矶(MC/C3)、和中国香港(邦联、沙田电信、大埔)、日本(东京、大阪)、新加坡、德国和荷兰等机房VPS主机,基于XEN或者KVM虚拟架构,均选择国内访问线路不错的机房,适合建...
优惠码50SSDOFF 首月5折50WHTSSD 年付5折15OFF 85折优惠,可循环使用荷兰VPSCPU内存SSD带宽IPv4价格购买1核1G50G1Gbps/3TB1个$ 9.10/月链接2核2G80G1Gbps/5TB1个$ 12.70/月链接2核3G100G1Gbps/7TB1个$ 16.30/月链接3核4G150G1Gbps/10TB1个$ 18.10/月链接阿联酋VPSCPU内存SS...