typename t_cst::size_type forward_search( const t_cst& cst, typename t_cst::node_type& v, const typename t_cst::size_type d, const typename t_cst::char_type c, typename t_cst::size_type& char_pos, SDSL_UNUSED typename std::enable_if<std::is_same<cst_tag, typename t_cst::index_category>::value, cst_tag>::type x = cst_tag() ) { unsigned char cc = cst.csa.char2comp[c]; // check if c occurs in the text of the csa if (cc==0 and cc!=c) // " " " " " " " " " " return 0; typename t_cst::size_type depth_node = cst.depth(v); if (d < depth_node) { // in an edge, no branching char_pos = cst.csa.psi[char_pos]; if (char_pos < cst.csa.C[cc] or char_pos >= cst.csa.C[cc+1]) return 0; return cst.size(v); } else if (d == depth_node) { // at a node, branching v = cst.child(v, c, char_pos); if (v == cst.root()) return 0; else return cst.size(v); } else { return 0; } }
typename t_cst::size_type forward_search(const t_cst& cst, typename t_cst::node_type& v, typename t_cst::size_type d, t_pat_iter begin, t_pat_iter end, typename t_cst::size_type& char_pos, SDSL_UNUSED typename std::enable_if<std::is_same<cst_tag, typename t_cst::index_category>::value, cst_tag>::type x = cst_tag() ) { if (begin==end) return cst.size(v); typename t_cst::size_type size=0; t_pat_iter it = begin; while (it != end and (size=forward_search(cst, v, d, *it, char_pos))) { ++d; ++it; } return size; }