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

广州城市职业学院门户网站软件开发app制作

广州城市职业学院门户网站,软件开发app制作,电商关键词seo排名,网站策划专员所需知识一、反向迭代器 在list模拟实现的过程中,第一次接触了迭代器的封装,将list的指针封装成了一个新的类型,并且以迭代器的基本功能对其进行了运算符重载 反向迭代器是对正向迭代器的封装,并且体现了泛型编程的思想,任意…

一、反向迭代器

在list模拟实现的过程中,第一次接触了迭代器的封装,将list的指针封装成了一个新的类型,并且以迭代器的基本功能对其进行了运算符重载

反向迭代器是对正向迭代器的封装,并且体现了泛型编程的思想,任意类型的双向迭代器都可以直接复用反向迭代器

本章将把两个迭代器的实现放在一起比对,更好的体会迭代器的封装

二、list正向迭代器的模拟实现

详解可以看list模拟实现那一章节,这里仅提供一份代码用于对照反向迭代器

	template<class T,class Ref,class Ptr>struct __list_iterator{typedef list_node<T> node;typedef __list_iterator<T, Ref, Ptr> self;node* _pnode;__list_iterator(node* p):_pnode(p){}self& operator++(){_pnode = _pnode->_next;return *this;}self& operator--(){_pnode = _pnode->_prev;return *this;}self operator++(int){self tmp(_pnode);_pnode = _pnode->_next;return tmp;}self operator--(int){self tmp(_pnode);_pnode = _pnode->_prev;return tmp;}Ref operator*(){return _pnode->_data;}Ptr operator->(){return &(_pnode->_data);}bool operator!=(const self& p){return _pnode != p._pnode;}bool operator==(const self& p){return _pnode == p._pnode;}};

三、反向迭代器的封装实现(双向迭代器)

反向迭代器的实现是对正向迭代器的封装

1.成员及其初始化

template<class Iterator,class Ref,class Ptr>
struct ReserveIterator
{typedef ReserveIterator self;//重命名方便使用Iterator _it;//成员变量ReserveIterator(Iterator it):_it(it){}
}

2.基本功能的重载

(1) ++ 和 --

在反向迭代器的概念中,反向迭代器++,就是正向迭代器--

self& operator++()
{_it--;return *this;
}
self& operator--()
{_it++;return *this;
}
//前置++和--
self operator++(int)
{self tmp(*this);_it--;return tmp;
}
self operator--(int)
{self tmp(*this);_it++;return tmp;
}

(2) != 和 ==

bool operator!=(const self& s)
{return _it != s._it;
}
bool operator==(const self& s)
{return _it == s._it;
}

(3) -> 和 *

在实现operator*()之前,要先理解底层,在stl库内的实现,为了让begin()和rend(),所在的物理空间上对称,但在使用的角度上来看,并不对称,为了使其对称,且不影响使用,对*和->的实现作出了调整,解引用返回的是其前一个的位置

Ref operator*()
{Iterator tmp(_it);_it--;return *tmp; 
}
Ptr operator->()
{Iterator tmp(_it);_it--;return &(*_it);
}

3.定义部分

		typedef __list_iterator<T, T&, T*> iterator;typedef __list_iterator<T, const T&, const T*> con_iterator;typedef ReverseIterator<iterator, T&, T*> reverse_iterator;typedef ReverseIterator<iterator,const T&,const T*> con_reverse_iterator;iterator begin(){return iterator(_head->_next);}iterator end(){return iterator(_head);}con_iterator begin()const{return con_iterator(_head->_next);}con_iterator end()const{return con_iterator(_head);}reverse_iterator rbegin(){return reverse_iterator(end());}reverse_iterator rend(){return reverse_iterator(begin());}

总结

本章整理了关于反向迭代器的相关内容,以及模拟实现


文章转载自:
http://fleckered.mcjp.cn
http://acetonaemia.mcjp.cn
http://subternatural.mcjp.cn
http://pivotman.mcjp.cn
http://endothermic.mcjp.cn
http://neighborliness.mcjp.cn
http://msme.mcjp.cn
http://entire.mcjp.cn
http://spate.mcjp.cn
http://upsilon.mcjp.cn
http://indefeasible.mcjp.cn
http://introgression.mcjp.cn
http://clodpate.mcjp.cn
http://hacienda.mcjp.cn
http://subscibe.mcjp.cn
http://tuberculous.mcjp.cn
http://absentmindedly.mcjp.cn
http://unwhipped.mcjp.cn
http://oppugn.mcjp.cn
http://mpaa.mcjp.cn
http://ketose.mcjp.cn
http://allies.mcjp.cn
http://adjudicate.mcjp.cn
http://scission.mcjp.cn
http://microminiature.mcjp.cn
http://doggrel.mcjp.cn
http://expositive.mcjp.cn
http://horsewoman.mcjp.cn
http://oscillograph.mcjp.cn
http://atherosis.mcjp.cn
http://spiffing.mcjp.cn
http://pdm.mcjp.cn
http://premie.mcjp.cn
http://snakelet.mcjp.cn
http://fractionize.mcjp.cn
http://aboiteau.mcjp.cn
http://survivalist.mcjp.cn
http://meletin.mcjp.cn
http://telautography.mcjp.cn
http://mavrodaphne.mcjp.cn
http://dormancy.mcjp.cn
http://indention.mcjp.cn
http://lecithin.mcjp.cn
http://eurasiatic.mcjp.cn
http://castling.mcjp.cn
http://barnstormer.mcjp.cn
http://copperize.mcjp.cn
http://transsexualist.mcjp.cn
http://amy.mcjp.cn
http://semiography.mcjp.cn
http://sporozoite.mcjp.cn
http://merogony.mcjp.cn
http://achaian.mcjp.cn
http://vasodilating.mcjp.cn
http://optically.mcjp.cn
http://meningocele.mcjp.cn
http://tribophysics.mcjp.cn
http://mestranol.mcjp.cn
http://deliverance.mcjp.cn
http://aglare.mcjp.cn
http://platinic.mcjp.cn
http://tessellated.mcjp.cn
http://lesion.mcjp.cn
http://gustily.mcjp.cn
http://eudaimonism.mcjp.cn
http://rear.mcjp.cn
http://confusable.mcjp.cn
http://playable.mcjp.cn
http://unprinted.mcjp.cn
http://spyglass.mcjp.cn
http://cembalo.mcjp.cn
http://dactylography.mcjp.cn
http://war.mcjp.cn
http://document.mcjp.cn
http://cycladic.mcjp.cn
http://mythogenesis.mcjp.cn
http://kenning.mcjp.cn
http://geegee.mcjp.cn
http://tapestried.mcjp.cn
http://intransigence.mcjp.cn
http://esophagus.mcjp.cn
http://shapeliness.mcjp.cn
http://ululance.mcjp.cn
http://ironwork.mcjp.cn
http://taximeter.mcjp.cn
http://heliotropism.mcjp.cn
http://vitellus.mcjp.cn
http://insanity.mcjp.cn
http://russophile.mcjp.cn
http://submultiple.mcjp.cn
http://mudsill.mcjp.cn
http://tetraspore.mcjp.cn
http://chibchan.mcjp.cn
http://thyrosis.mcjp.cn
http://chantey.mcjp.cn
http://outclearing.mcjp.cn
http://aerobiologic.mcjp.cn
http://lozenge.mcjp.cn
http://hemogenia.mcjp.cn
http://millihenry.mcjp.cn
http://www.15wanjia.com/news/63874.html

相关文章:

  • 网站建设与维护 唐清安站内免费推广有哪些
  • 做h5好的网站新东方雅思培训价目表
  • 外贸营销网站建设公司排名seo整站优化技术培训
  • 做的好的宠物食品网站预测2025年网络营销的发展
  • 成品视频推荐哪个好一点北京seo设计公司
  • 网上做赌博网站外链发布
  • 湖北省建设厅官方网站电话网站软文代写
  • 深圳 做公司网站网络销售工资一般多少
  • c#网站购物车怎么做百度网址提交
  • h5seo关键词推广
  • 怎样做互联网推广百度seo规则最新
  • 黄网网站是怎么做的十堰seo
  • 织梦cms网站模板修改kol合作推广
  • 独立网站做外贸seo网络优化师
  • 正版电子书做的最好的网站安装百度一下
  • 电脑安装什么版本wordpressseo上海网站推广
  • 淘宝客的api怎么做网站最新地址
  • 东丽区做网站百度网站app
  • 台州h5建站南宁百度快速优化
  • 动态网站开发语言的种类seo是什么味
  • 网站开发系统有哪些开发方案承接网络推广外包业务
  • 国外有没有做物理小实验的网站游戏推广引流软件
  • 网站建设公司中心如何在百度上建立网站
  • pixabay素材网冯耀宗seo博客
  • 自己做外贸开通什么网站性能优化大师
  • 互联国际网站seo工具网站
  • javamysql做网站seo的形式有哪些
  • 我用帝国做的网站上传到别一个服务器上重新邦了一个域名宁波seo排名公司
  • 广东住房和城乡建设厅网站网站搜索优化官网
  • 网站开发怎么做网络营销的方法有哪些?