remove \r
[extl.git] / extl / container / detail / indirected_net_adjnode_iterator.h
blobcba62822a0fd1fc5660c94f8a9a778e5012af1d9
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: indirected_net_adjnode_iterator.h
4 * Created: 08.12.04
5 * Updated: 08.12.04
7 * Brief: The indirected_net_adjnode_iterator class
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
13 #ifndef EXTL_CONTAINER_DETAIL_INDIRECTED_NET_ADJNODE_ITERATOR_H
14 #define EXTL_CONTAINER_DETAIL_INDIRECTED_NET_ADJNODE_ITERATOR_H
16 /* ///////////////////////////////////////////////////////////////////////
17 * Includes
19 #include "../prefix.h"
21 /* ///////////////////////////////////////////////////////////////////////
22 * ::extl::detail namespace
24 EXTL_BEGIN_NAMESPACE
25 EXTL_DETAIL_BEGIN_NAMESPACE
27 template< typename_param_k NodBuf
28 , typename_param_k AdjMtx
30 class const_indirected_net_adjnode_iterator
31 : public const_bidirectional_iterator_base < const_indirected_net_adjnode_iterator<NodBuf, AdjMtx>
32 , typename_type_k NodBuf::index_type
33 , e_ptrdiff_t
36 private:
37 typedef const_bidirectional_iterator_base < const_indirected_net_adjnode_iterator<NodBuf, AdjMtx>
38 , typename_type_k NodBuf::index_type
39 , e_ptrdiff_t
40 > base_type;
41 typedef base_type iterator_base_type;
42 typedef e_size_t size_type;
43 typedef size_type index_type;
44 typedef e_bool_t bool_type;
45 typedef NodBuf nodes_type;
46 typedef AdjMtx adjmtx_type;
47 typedef typename_type_k adjmtx_type::const_rowe_iterator const_rowe_iterator;
49 public:
50 typedef const_indirected_net_adjnode_iterator class_type;
51 typedef typename_type_k iterator_base_type::iterator_category iterator_category;
52 typedef typename_type_k iterator_base_type::value_type value_type;
53 typedef typename_type_k iterator_base_type::reference reference;
54 typedef typename_type_k iterator_base_type::const_reference const_reference;
55 typedef typename_type_k iterator_base_type::pointer pointer;
56 typedef typename_type_k iterator_base_type::const_pointer const_pointer;
57 typedef typename_type_k iterator_base_type::difference_type difference_type;
59 private:
60 const_rowe_iterator m_current;
61 nodes_type const* m_pnodes;
62 adjmtx_type const* m_padjmtx;
63 index_type m_id;
65 public:
66 const_indirected_net_adjnode_iterator()
67 : m_current()
68 , m_pnodes(NULL)
70 const_indirected_net_adjnode_iterator(index_type id, const_rowe_iterator current, nodes_type const& ns, adjmtx_type const& atx)
71 : m_current(current)
72 , m_pnodes(&ns)
73 , m_padjmtx(&atx)
74 , m_id(id)
76 for (; m_current != adjmtx().rowe_end(m_id) && (*m_current).is_empty(); ++m_current);
78 const_indirected_net_adjnode_iterator(class_type const& it)
79 : m_current(it.m_current)
80 , m_pnodes(it.m_pnodes)
81 , m_padjmtx(it.m_padjmtx)
82 , m_id(it.m_id)
85 public:
86 const_rowe_iterator current() const { return m_current; }
88 private:
89 nodes_type const& nodes() const { EXTL_ASSERT(NULL != m_pnodes); return *m_pnodes; }
90 adjmtx_type const& adjmtx() const { EXTL_ASSERT(NULL != m_padjmtx); return *m_padjmtx; }
92 void next()
94 for (; ++m_current != adjmtx().rowe_end(m_id) && (*m_current).is_empty(); );
96 void prev()
98 for (; --m_current != adjmtx().rowe_begin(m_id) && (*m_current).is_empty(); );
99 if (m_current == adjmtx().rowe_begin(m_id) && (*m_current).is_empty())
100 m_current = adjmtx().rowe_end(m_id);
103 public:
104 void do_increase()
106 next();
108 void do_decrease()
110 prev();
112 const_reference do_dereference() const
114 return ((m_id != (*current()).end_id())? (*current()).end_id()
115 : (m_id != (*current()).begin_id()? (*current()).begin_id() : m_id));
117 bool_type do_equal(class_type const& rhs) const
119 return (m_pnodes == rhs.m_pnodes)
120 && (m_padjmtx == rhs.m_padjmtx)
121 && (m_id == rhs.m_id)
122 && (current() == rhs.current());
127 /* ///////////////////////////////////////////////////////////////////////
128 * ::extl::detail namespace
130 EXTL_DETAIL_END_NAMESPACE
131 EXTL_END_NAMESPACE
132 /* //////////////////////////////////////////////////////////////////// */
133 #endif /* EXTL_CONTAINER_DETAIL_INDIRECTED_NET_ADJNODE_ITERATOR_H */
134 /* //////////////////////////////////////////////////////////////////// */