当前位置: 首页 > news >正文

洛阳网站推广方式百度网站电话是多少

洛阳网站推广方式,百度网站电话是多少,海外电商平台有哪些,深圳做网站的list库实现的要点&#xff1a; 构建list类时&#xff0c;需要同时构建struct Node来存储节点信息&#xff0c;list类中只存储哨兵位节点信息&#xff0c;迭代器类需要template<T,Ptr,Ref>来构建const和非const迭代器&#xff0c;迭代器中也是存储节点信息。反向迭代器也…

list库实现的要点:

构建list类时,需要同时构建struct Node来存储节点信息,list类中只存储哨兵位节点信息,迭代器类需要template<T,Ptr,Ref>来构建const和非const迭代器,迭代器中也是存储节点信息。反向迭代器也是同样道理,但是可以用迭代器来构建反向迭代器。具体代码如下 

#include<iostream>
#include<assert.h>
#include<algorithm>
using namespace std;template<class T>
struct __list_node
{__list_node(const T& val = T()):_data(val),_prev(nullptr),_next(nullptr){}__list_node* _prev;__list_node* _next;T _data;
};//构建每个节点//构建迭代器struct
template<class T, class Ptr, class Ref>
struct __list_iterator
{typedef __list_node<T> Node;typedef __list_iterator<T, Ptr, Ref> Self;Node* _node;//成员变量还是节点,只是在成员函数做手脚__list_iterator(Node* val ):_node(val){}Self& operator++(){_node = _node->_next;return *this;}Self operator++(int)//后置{Self tmp = *this;++(*this);return tmp;}Self& operator--(){_node = _node->_prev;return *this;}Self operator--(int){Self tmp = *this;--(*this);return tmp;}Ptr operator->(){return &(_node->_data);}Ref operator*(){return _node->_data;}bool operator!= ( const Self& val ){return !(_node == val._node);}};
template<class T,class Ptr,class Ref>
struct __list_reverse_iterator
{typedef __list_iterator<T, T*, T&> iterator;typedef __list_reverse_iterator<T, T*, T&> Self;iterator _it;__list_reverse_iterator(iterator it):_it(it){}Self operator++(){_it = _it._node->_prev;return *this;}T& operator*(){return _it._node->_data;}bool operator!=(const Self& rit){return !(_it._node == rit._it._node);}};//构建双向带头循环链表
template<class T>
class list
{typedef __list_node<T> Node;
public:typedef __list_iterator<T,T*,T&> iterator;typedef __list_iterator<T, const T*, const T&> const_iterator;typedef __list_reverse_iterator<T, T*, T&> reverse_iterator;reverse_iterator rbegin(){return reverse_iterator(--end());}reverse_iterator rend(){return reverse_iterator(end());}iterator begin(){return iterator(_phead->_next);}const_iterator begin()const{return const_iterator(_phead->_next);}iterator end(){return iterator(_phead);}const_iterator end()const{return const_iterator(_phead);}list()//开头空间,初始化{_phead = new Node;_phead->_next = _phead;_phead->_prev = _phead;}~list(){clear();delete _phead;_phead = nullptr;}//拷贝构造(先创建一个哨兵位,然后再pushback)list(const list<T>& l){_phead = new Node;_phead->_next = _phead;_phead->_prev = _phead;for (auto& x : l){push_back(x);}}list<T>& operator=(const list<T>& l){list<T> tmp(l);swap(_phead, tmp._phead);return *this;}//尾插入void push_back(const T& val){//Node* tail = _phead->_prev;//Node* newnode = new Node(val);更变链接//tail->_next = newnode;//newnode->_prev = tail;//newnode->_next = _phead;//_phead->_prev = newnode;insert(end(), val);}//头插void push_front(const T& val){insert(begin(), val);}//头删除void pop_front(){erase(begin());}//尾删除void pop_back(){erase(--end());}//清空节点(除了哨兵位,都清除)void clear(){iterator it = begin();while (it != end()){it = erase(it);}}//随机插入void insert(iterator pos, const T& val){Node* pcur = pos._node;Node* prev = pcur->_prev;Node* newnode = new Node(val);//构建联系newnode->_prev = prev;newnode->_next = pcur;prev->_next = newnode;pcur->_prev = newnode;}//删除指定位置(不能将哨兵位删掉!!iterator erase(iterator pos){assert(pos != end());Node* pcur = pos._node;Node* prev = pcur->_prev;Node* next = pcur->_next;delete pcur;pcur = nullptr;prev->_next = next;next->_prev = prev;return iterator(next);}private:Node* _phead;
};

http://www.ds6.com.cn/news/87149.html

相关文章:

  • 佛山企业网站建设公司企业广告宣传
  • 教您如何申请企业邮箱win7优化大师好不好
  • 网站设计制作报告百度网站网址是多少
  • 织梦网站空间如何清理客服系统网页源码2022免费
  • win不用iis做网站站点搜索
  • 网站+做内容分发资格湖南疫情最新消息今天
  • wordpress随机注册seo诊断报告
  • 做网站所需知识百度推广运营工作是什么
  • wordpress后台运行速度慢新网seo关键词优化教程
  • 网站翻页模板优化公司排名
  • Ul设计网站推广普通话心得体会
  • 做投资的网站好百度seo排名
  • 济南建网站公司价格微网站
  • 怎么找人做网站啊营销网站方案设计
  • 昆明餐饮网站建设seo基础篇
  • 精美ppt模板下载免费seo推广的网站和平台有哪些
  • 网站建设咨询公司哪里可以建网站
  • 喀什做网站关键词排名哪里查
  • 建个企业网站对公司宣传有用吗seo是什么职业岗位
  • .tv做网站怎么样谷歌应用商店app下载
  • 建网站 发信息 做推广长沙百度关键词推广
  • 网站怎么做点击广告代写文章兼职
  • dwcs5做网站武汉武汉最新
  • 做专利费减是哪个网站唯尚广告联盟app下载
  • 楚雄网站开发百度搜索推广的五大优势
  • 做网站一定要域名吗类似火脉的推广平台
  • 证券公司网站建设方案嘉兴seo排名外包
  • 个人帮企业做网站如何优化网络速度
  • 做网站找不到客户抖音矩阵排名软件seo
  • 莱芜地板街50一次海外seo培训