|  | 
|  | 1 | +#ifndef INCLUDED_SDSL_SUFFIX_TREE_HELPER | 
|  | 2 | +#define INCLUDED_SDSL_SUFFIX_TREE_HELPER | 
|  | 3 | + | 
|  | 4 | +#include <stdint.h> | 
|  | 5 | +#include <cstdlib> | 
|  | 6 | +#include <cassert> | 
|  | 7 | +#include "iterators.hpp" | 
|  | 8 | + | 
|  | 9 | +namespace sdsl | 
|  | 10 | +{ | 
|  | 11 | + | 
|  | 12 | + | 
|  | 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 | + | 
|  | 42 | +template <class t_cst> | 
|  | 43 | +class cst_node_child_proxy | 
|  | 44 | +{ | 
|  | 45 | +    public: // types | 
|  | 46 | +        using iterator_type = cst_node_child_proxy_iterator<t_cst>; | 
|  | 47 | +        using node_type = typename t_cst::node_type; | 
|  | 48 | +        using size_type = typename t_cst::size_type; | 
|  | 49 | +    private: // data | 
|  | 50 | +        const node_type& m_parent; | 
|  | 51 | +        const t_cst& m_cst; | 
|  | 52 | +    public: // constructors | 
|  | 53 | +        cst_node_child_proxy() = delete; | 
|  | 54 | +        explicit cst_node_child_proxy(const t_cst& cst,const node_type& v) : m_parent(v) , m_cst(cst) {}; | 
|  | 55 | +    public: // methods | 
|  | 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()); } | 
|  | 60 | +}; | 
|  | 61 | + | 
|  | 62 | +} | 
|  | 63 | + | 
|  | 64 | +#endif | 
0 commit comments