@@ -10,28 +10,55 @@ namespace sdsl
1010{
1111
1212
13+ template <class t_cst >
14+ class cst_node_child_proxy_iterator
15+ {
16+ public:
17+ using node_type = typename t_cst::node_type;
18+ using const_reference = const node_type;
19+ using iterator_type = cst_node_child_proxy_iterator<t_cst>;
20+ private:
21+ const t_cst& m_cst;
22+ node_type current_node;
23+ public:
24+ cst_node_child_proxy_iterator () = delete ;
25+ cst_node_child_proxy_iterator (const t_cst& cst,const node_type& v) : m_cst(cst) , current_node(v) {}
26+ public:
27+ const_reference operator *() const {
28+ return current_node;
29+ }
30+ iterator_type& operator ++() {
31+ current_node = m_cst.sibling (current_node);
32+ return *this ;
33+ }
34+ bool operator ==(const iterator_type& it)const {
35+ return it.current_node == current_node;
36+ }
37+ bool operator !=(const iterator_type& it)const {
38+ return !(*this ==it);
39+ }
40+ };
41+
1342template <class t_cst >
1443class cst_node_child_proxy
1544{
1645 public: // types
17- using iterator_type = random_access_const_iterator<cst_node_child_proxy >;
46+ using iterator_type = cst_node_child_proxy_iterator<t_cst >;
1847 using node_type = typename t_cst::node_type;
1948 using size_type = typename t_cst::size_type;
20- using difference_type = size_type;
21- using value_type = node_type;
2249 private: // data
2350 const node_type& m_parent;
2451 const t_cst& m_cst;
2552 public: // constructors
2653 cst_node_child_proxy () = delete ;
2754 explicit cst_node_child_proxy (const t_cst& cst,const node_type& v) : m_parent(v) , m_cst(cst) {};
2855 public: // methods
29- value_type operator [](size_type i) const { return m_cst.select_child (m_parent,i+1 ); } // enumeration starts with 1 not 0
30- iterator_type begin () const { return iterator_type (this ); }
31- iterator_type end () const { return iterator_type (this ,m_cst.degree (m_parent)); }
56+ node_type operator [](size_type i) const { return m_cst.select_child (m_parent,i+1 ); } // enumeration starts with 1 not 0
57+ size_type size () { return m_cst.degree (m_parent); }
58+ iterator_type begin () const { return iterator_type (m_cst,m_cst.select_child (m_parent,1 )); }
59+ iterator_type end () const { return iterator_type (m_cst,m_cst.root ()); }
3260};
3361
34-
3562}
3663
3764#endif
0 commit comments