123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #pragma once
- #include "ReverseIterator.Base.tlh"
- #include "ReverseIterator.Random.tlh"
- //-----------------------------------------------------------------------------
- // Iterator
- // 一般容器 - 常量
- //-----------------------------------------------------------------------------
- namespace ReverseIterator
- {
- template <typename _Container>
- class __ConstIterator : public __RandomIterator <typename _Container::const_reverse_iterator>
- {
- typedef __RandomIterator <typename _Container::const_reverse_iterator> inherited;
- public:
- // using value_type = _Container.value_type;
- using reference = typename _Container::reference;
- using const_reference = typename _Container::const_reference;
- public:
- // 构造一个全空的迭代器, 用于容器指针为空的情形
- __ConstIterator () : inherited ()
- {
- }
- __ConstIterator (const _Container & ar)
- {
- Iter = _begin = ar.crbegin ();
- _end = ar.crend ();
- m_Count = (int) ar.size ();
- m_Index = m_Count - 1;
- }
- __ConstIterator (const __ConstIterator & from)
- {
- CopyAssign (from);
- }
- __ConstIterator (__ConstIterator && from)
- {
- MoveAssign (from);
- }
- ~__ConstIterator () {}
- public:
- inline __ConstIterator & operator = (const __ConstIterator & from)
- {
- CopyAssign (from);
- return (*this);
- }
- public:
- inline const_reference Current ()
- {
- return (*Iter);
- }
- inline const_reference operator () (void) { return Current (); }
- inline const_reference operator * (void) { return Current (); }
- };
- };
- //-----------------------------------------------------------------------------
- // Iterator
- // 一般容器 - 变量
- //-----------------------------------------------------------------------------
- namespace ReverseIterator
- {
- template <typename _Container>
- class __Iterator : public __RandomIterator <typename _Container::reverse_iterator>
- {
- typedef __RandomIterator <typename _Container::reverse_iterator> inherited;
- public:
- // using value_type = _Container.value_type;
- using reference = typename _Container::reference;
- public:
- // 构造一个全空的迭代器, 用于容器指针为空的情形
- __Iterator () : inherited ()
- {
- }
- __Iterator (_Container & ar)
- {
- Iter = _begin = ar.rbegin ();
- _end = ar.rend ();
- m_Count = (int) ar.size ();
- m_Index = m_Count - 1;
- }
- __Iterator (const __Iterator & from)
- {
- CopyAssign (from);
- }
- __Iterator (__Iterator && from)
- {
- MoveAssign (from);
- }
- ~__Iterator () {}
- public:
- inline __Iterator & operator = (const __Iterator & from)
- {
- CopyAssign (from);
- return (*this);
- }
- public:
- inline reference Current ()
- {
- return (*Iter);
- }
- inline reference operator () (void) { return Current (); }
- inline reference operator * (void) { return Current (); }
- };
- }
|