温故知新
来源:互联网 发布:怎样关闭服务器80端口 编辑:程序博客网 时间:2024/04/27 10:25
#include <cstdio>#include <iostream>using namespace std;/* *循环双向链表 *insert,splice 都不会造成原有的list迭代器失效. **/template <class T>struct _list_node { typedef void * void_pointer; void_pointer prev; void_pointer next; T data;};template <typename T, typename Ref, typename Ptr>struct _list_iterator { typedef _list_iterator<T, T&, T*> iterator; typedef _list_iterator<T, Ref, Ptr> self; typedef bidirectional_iterator_tag iterator_category;//双向指针尾 typedef T value_type; typedef Ptr pointer; typedef Ref reference; typedef _list_node<T> * link_type; typedef size_t size_type; typedef ptrdiff_t difference_type; link_type node;//迭代器内部当然要有一个普通指针,指向list的节点 //constructor _list_iterator(link_type x) : node(x) {} _list_iterator() {} _list_iterator(const iterator & x) :node(x.node){} bool operator == (const self & x) const { return node == x.node;} bool operator != (const self & x) const { return node != x.node;} reference operator*()const {return (*node).data;} pointer operator->() const {return &(operator *());} self & operator++() { node = (link_type)((*node).next); return *this; } self operator++(int) { self tmp = *this; ++*this; return tmp; } self & operator--() { node = (link_type)((*node).prev); return *this; } self operator--(int) { self tmp = *this; --*this; return tmp; } };int main(){ while (1) ; return 0;}
细看,细读.慢慢品味,发现其中无穷乐趣啊.
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 温故知新
- 【小结】温故知新
- hibernate温故知新
- CSS温故知新
- 今日温故知新
- 今日温故知新
- 今日温故知新
- 树表查找之二叉排序树
- tbr tbn tbc
- android:SDL init failure, reason is: No available video device
- 四则运算,简单的,只有个位数加减
- 解析成功手机游戏的10种特征和共性
- 温故知新
- 黑马程序员_html常用标签1
- python2.5中使用OpenCV
- 'PIO_STACK_LOCATION' : illegal use of this type as an expression
- 黑马程序员_html常用标签2
- windows消息列表
- js跳转页面方法(转)
- 黑马程序员_html常用标签3
- 黑马程序员_html常用标签4