# 线性表——链式描述(双向链表)

```template<class T>
class iterator
{
public:
//向前迭代
typedef forward_iterator_tag iterator_category;
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
typedef T& reference;

//构造函数
iterator(chainNode<T> * theNode = NULL)
{
node = theNode;
}
//解引用操作符
T& operator*() const
{
return node->element;
}
T* operator->() const
{
return &node->element;
}

//迭代器加法操作
iterator& operator++()//前加
{
node = node->next;
return *this;
}
iterator operator++(int)//后加
{
iterator old = *this;
node = node->next;
return old;
}

//相等检验
bool operator != (const iterator right) const
{
return node != right.node;
}
bool operator == (const iterator right) const
{
return node == right.node;
}
protected:
chainNode<T>* node;

};

iterator begin()
{
return iterator(firstNode);
}

iterator end()
{
return irerator(NULL);
}```

136 篇文章39 人订阅

0 条评论

## 相关文章

2094

2654

2558

### Gym 100952J&&2015 HIAST Collegiate Programming Contest J. Polygons Intersection【计算几何求解两个凸多边形的相交面积板子题

J. Polygons Intersection time limit per test：2 seconds memory limit per test：64 ...

2757

2234

41710

13310

2322

3457

3675