remove \r
[extl.git] / extl / container / detail / net_in_adjnode_iterator.h
blob1f4c018bfcb1adec8a54d92bdf78f668245421b8
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: net_in_adjnode_iterator.h
4 * Created: 08.12.04
5 * Updated: 08.12.04
7 * Brief: The net_in_adjnode_iterator class
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
13 #ifndef EXTL_CONTAINER_DETAIL_NET_IN_ADJNODE_ITERATOR_H
14 #define EXTL_CONTAINER_DETAIL_NET_IN_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_net_in_adjnode_iterator
31 : public const_bidirectional_iterator_base < const_net_in_adjnode_iterator<NodBuf, AdjMtx>
32 , typename_type_k NodBuf::index_type
33 , e_ptrdiff_t
36 private:
37 typedef const_bidirectional_iterator_base < const_net_in_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_cole_iterator const_cole_iterator;
49 public:
50 typedef const_net_in_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_cole_iterator m_current;
61 nodes_type const* m_pnodes;
62 adjmtx_type const* m_padjmtx;
63 index_type m_id;
65 public:
66 const_net_in_adjnode_iterator()
67 : m_current()
68 , m_pnodes(NULL)
70 const_net_in_adjnode_iterator(index_type id, const_cole_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().cole_end(m_id) && (*m_current).is_empty(); ++m_current);
78 const_net_in_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_cole_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().cole_end(m_id) && (*m_current).is_empty(); );
96 void prev()
98 for (; --m_current != adjmtx().cole_begin(m_id) && (*m_current).is_empty(); );
99 if (m_current == adjmtx().cole_begin(m_id) && (*m_current).is_empty())
100 m_current = adjmtx().cole_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 (*current()).begin_id();
116 bool_type do_equal(class_type const& rhs) const
118 return (m_pnodes == rhs.m_pnodes)
119 && (m_padjmtx == rhs.m_padjmtx)
120 && (m_id == rhs.m_id)
121 && (current() == rhs.current());
126 /* ///////////////////////////////////////////////////////////////////////
127 * ::extl::detail namespace
129 EXTL_DETAIL_END_NAMESPACE
130 EXTL_END_NAMESPACE
131 /* //////////////////////////////////////////////////////////////////// */
132 #endif /* EXTL_CONTAINER_DETAIL_NET_IN_ADJNODE_ITERATOR_H */
133 /* //////////////////////////////////////////////////////////////////// */