Exemple #1
0
	//! Prefix increment of the iterator.
	iterator& operator++()
	{
		if (!m_valid) return *this;
		if (m_v == m_cst->root() and m_visited) {
			m_valid = false;
			return *this;
		}
		value_type w;
		if (!m_visited) { // go down, if possible
			if (m_cst->is_leaf(m_v)) {
				w = m_cst->sibling(m_v);  // determine sibling of leaf v
				if (w == m_cst->root()) { // if there exists no right sibling of the leaf v
										  //					w = m_cst->parent(m_v);
					w		  = parent();
					m_visited = true; // go up
				}
			} else { // v is not a leaf => go down the tree
				w = first_child();
			}
		} else { //
			w = m_cst->sibling(m_v);
			if (w == m_cst->root()) { // if there exists no right sibling
				w = parent();
			} else {
				m_visited = false;
			}
		}
		m_v = w;
		return *this;
	}
void test_cst_sibling_operation(const Cst& cst, typename Cst::size_type times=100000, uint64_t x=17)
{
    typedef typename Cst::size_type size_type;
    typedef typename Cst::node_type node_type;

    std::vector<node_type> nodes;
    generate_nodes_from_random_leaves(cst, times, nodes, x);
    for (size_type i=0; i<nodes.size(); ++i) {
        nodes[i] = cst.sibling(nodes[i]);
    }

    node_type c;  // for sibling node
    size_type cnt=0;
    write_R_output("cst","sibling","begin",nodes.size(),cnt);
    for (size_type i=0; i<nodes.size(); ++i) {
        c = cst.sibling(nodes[i]);
        if (c==cst.root())
            ++cnt;
    }
    write_R_output("cst","sibling","end",nodes.size(),cnt);
}
Exemple #3
0
	//! Prefix increment of the iterator.
	iterator& operator++()
	{
		if (!m_valid) return *this;
		if (m_v == m_cst->root()) {
			m_valid = false;
			return *this;
		}
		value_type w = m_cst->sibling(m_v);
		if (w == m_cst->root()) {		   // if no next right sibling exist
			m_v = m_cst->parent(m_v);	  // go to parent
		} else {						   // if next right sibling exist
			m_v = m_cst->leftmost_leaf(w); // go to leaftmost leaf in the subtree of w
		}
		return *this;
	}
Exemple #4
0
	//! Prefix increment of the iterator.
	iterator& operator++()
	{
		if (!m_valid) return *this;
		if (m_queue.empty()) {
			m_valid = false;
			return *this;
		}
		value_type v = m_queue.front();
		m_queue.pop();
		value_type child = m_cst->select_child(v, 1);
		while (m_cst->root() != child) {
			m_queue.push(child);
			child = m_cst->sibling(child);
		}
		return *this;
	}