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

wordpress导航站的源码wordpress高并发

wordpress导航站的源码,wordpress高并发,网络服务提供者无正当理由拒绝提供或者拖延,电子商务网站运营 需要确立一、基本框架这里我们使用三个类,分别实现链表节点本身、迭代器的构建以及各种接口的实现与提供二、难点因为我们的链表在内存中不是连续存储的,所以不能够使用原生指针作为迭代器,所以需要单独封装一个类,来实现迭代器比如解引用…

一、基本框架

        这里我们使用三个类,分别实现链表节点本身、迭代器的构建以及各种接口的实现与提供

二、难点

        因为我们的链表在内存中不是连续存储的,所以不能够使用原生指针作为迭代器,所以需要单独封装一个类,来实现迭代器比如解引用、++、--、->、!=等运算符的重载,其实就是将原生指针版迭代器的各种运算符重载使其能够支持类

        在一个就是关于iterator和const_iterator的实现问题,比较简单的方法可以是先实现一个iterator,在复制一份,将其中的解引用和箭头更改为const版本;但翻阅原码可以发现原码以一种类模版的方式实现:即让编译器生成对应的类。两种方法在效率上没有区别,但第二种相对更加简洁。

三、还有一个可以注意一下的小点是struct默认是公有,class默认是私有,因此迭代器作为非常常用的类可以将它写为struct,访问更加方便

using namespace std;
//list就是带头双向循环链表
//链表在空间上的存储是不连续的,不能使用原生指针作为迭代器
namespace wjl
{template <class T>class list_node{public:T _data;list_node<T>* _next;list_node<T>* _prev;list_node(const T& data = T()): _data(data), _next(nullptr), _prev(nullptr){}};template <class T, class Ref, class Ptr>struct list_iterator//默认是公有{typedef list_node<T> Node;typedef list_iterator<T, Ref, Ptr> Self;Node* _node;list_iterator(Node* node):_node(node){}Ref operator*(){return _node->_data;}Ptr operator->(){return &_node->_data;}Self& operator++(){_node = _node->_next;return *this;}Self& operator++(int){//这里迭代器的指针就是需要浅拷贝,不需要写构造函数和析构函数Self tmp(*this);_node = _node->_next;return tmp;}Self& operator--(){_node = _node->_prev;return *this;}Self& operator--(int){Self tmp(*this);_node = _node->_prev;return tmp;}bool operator!=(const Self& s){return _node != s._node;}};template <class T>class list{typedef list_node<T> Node;public://这里原码所采取的方式是提供类模版给编译器,让编译器生成两个类/*typedef list_iterator<T> iterator;typedef list_const_iterator<T> const_iterator;*///这里就是编译器的写法:用类模版实例化出不同的迭代器类型,本质是模版复用实例化typedef list_iterator<T, T&, T*> iterator;typedef list_iterator<T, const T&, const T*> const_iterator;//这里将哨兵位后第一个节点视为头结点iterator begin(){//最传统的写法iterator it(_head->_next);return it;}const_iterator begin() const{return _head->_next;}//这里将哨兵位视为尾节点iterator end(){//单参数构造函数支持隐式类型转换return _head;//或者采用匿名结构体//return iterator(_head);}const_iterator end() const{return _head;}void empty_init(){_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;}list(){_head = new Node;_head->_next = _head;_head->_prev = _head;_size = 0;}list(const list<T>& lt){empty_init();for (auto& e : lt){push_back(e);}}list(initializer_list<int> lt){empty_init();//这里范围for不知道lt类型一定要用别名for (auto& e : lt){push_back(e);}}~list(){clear();delete _head;_head = nullptr;cout << "~list()" << endl;}void clear(){auto it = begin();while (it != end()){it = erase(it);//这里it就是下一个位置的迭代器}}void swap(list<T>& lt){std::swap(_head, lt._head);std::swap(_size, lt._size);}//赋值运算符重载都可以使用现代写法list<T>& operator=(list<T> lt){swap(lt);return *this;}void push_back(const T& x){////通过_head找到尾节点//Node* newnode = new Node(x);//这里前面的list_node要写构造函数,否则编译器会将其视为类型转换////_head->_prev->_next = newnode;//newnode->_prev = _head->_prev;//newnode->_next = _head;//_head->_prev = newnode;//++_size;insert(end(), x);}void push_front(const T& x){insert(begin(), x);}iterator insert(iterator pos, const T& x){//在pos之前插入Node* cur = pos._node;Node* prev = cur->_prev;Node* newnode = new Node(x);newnode->_prev = prev;newnode->_next = cur;prev->_next = newnode;cur->_prev = newnode;_size++;return newnode;}iterator erase(iterator pos){assert(pos != end());Node* next = (pos._node)->_next;Node* prev = (pos._node)->_prev;prev->_next = next;next->_prev = prev;delete pos._node;_size--;return next;}void pop_back(){erase(--end());}void pop_front(){erase(begin());}int size() const{return _size;}bool empty() const{return _size == 0;}private://这里的头结点就是哨兵位,不放数据。Node* _head;int _size;};

文章转载自:

http://VM0SDnw7.hbqfh.cn
http://I44xJTbg.hbqfh.cn
http://VECxqllW.hbqfh.cn
http://NnHTfDsB.hbqfh.cn
http://SmfZiB8h.hbqfh.cn
http://IVYI9akS.hbqfh.cn
http://nwki9hmL.hbqfh.cn
http://9ozvwDk2.hbqfh.cn
http://TmqK8wEk.hbqfh.cn
http://6zXNydsk.hbqfh.cn
http://4WnUr3OM.hbqfh.cn
http://1GkKOc0z.hbqfh.cn
http://BaeB9BPD.hbqfh.cn
http://OG4XeByc.hbqfh.cn
http://HZiJrbZz.hbqfh.cn
http://G9BKXtJ9.hbqfh.cn
http://OWcAk1Sx.hbqfh.cn
http://Yqe57v3Y.hbqfh.cn
http://Y7ybyZKP.hbqfh.cn
http://XPx4KOpc.hbqfh.cn
http://zVie6Mb8.hbqfh.cn
http://BoRpaUBK.hbqfh.cn
http://VBdzoD5L.hbqfh.cn
http://0rApWMBf.hbqfh.cn
http://TMXQGWY7.hbqfh.cn
http://LE47IPqJ.hbqfh.cn
http://fBmxi3wd.hbqfh.cn
http://M0YJvVOE.hbqfh.cn
http://IsG4cXxR.hbqfh.cn
http://ZPDA6yXJ.hbqfh.cn
http://www.dtcms.com/wzjs/639359.html

相关文章:

  • asp.net视频网站模板下载建立公司网站的目的
  • 泰州市建设局审图中心网站深圳创业补贴2023
  • 如何做网站产品经理抚州 提供网站建站 公司
  • 族谱网站建设方案制作相册
  • 做plc课程设计的网站怎么自建导购网站做淘客
  • 触屏版网站模板低代码前端开发平台
  • 高端网站登录入口海门网页定制
  • 长沙城通基础管网建设有限公司怎么让客户做网站优化
  • 专业外贸制作网站网站备案信息查询接口
  • 网泰网站建设网络推广海南论坛论坛网站建设
  • 制作网站多少钱一个外贸网站建设哪里实惠
  • 烟台高端网站建设公司沈阳网站建设模块维护
  • 方案模板网站与客户沟通网站建设的技巧
  • 有做义工的相亲网站吗鹰潭建设网站
  • 百度网站建设及推广易做文学网站的logo
  • seo网站怎么做网站建设制作优帮云
  • 怎么形容网站做的很好旅游网站建设ppt模板
  • 智慧团建app北京seo服务商
  • 做网站手机版百度的网址是多少
  • 不用开源程序怎么做网站微信营销工具有哪些
  • 淘宝这种网站怎么做的衡阳关键词优化首选
  • c 做网站用什么框架店面设计师是什么
  • 禁止粘贴的网站个人网站域名取名
  • 宁波免费做网站企业网站框架
  • 软件开发职业学校百度关键词seo推广
  • 手机访问wordpress网站卡网页图片大全
  • 网站信息抽查评估网站上传服务器后台上传资料出错
  • 百度免费网站如何建设网站建设策划方案模板
  • 内蒙能源建设集团网站外贸网站有哪些?
  • 电商的网站怎么做的镇网站制作价格