Exemplo n.º 1
0
template<class KEY, class VALUE> Nde* Nde::left_sibling (int& parent_index_this) {
    parent_index_this = index_has_subtree (); // for element with THIS as subtree
    if (parent_index_this == invalid_index)
        return 0;
    // now mp_parent is known not to be null
    if (parent_index_this==0)
        return 0;  // no left sibling
    return mp_parent->m_vector[parent_index_this-1].mp_subtree;  // might be null
}
Exemplo n.º 2
0
int left_sibling (PBTREE btree, int node_idx, int *parent_index_this) {
    int parent_node_idx = btree->nodes[node_idx].parent_node_idx;
    *parent_index_this = index_has_subtree (btree, node_idx); // for element with THIS as subtree
    if (!BTREE_IS_VALID_ELEMENT_IDX(*parent_index_this))
        return BTREE_INVALID_NODE_IDX;
    // now mp_parent is known not to be null
    if (*parent_index_this==0)
        return BTREE_INVALID_NODE_IDX;  // no left sibling
    return btree->nodes[parent_node_idx].elements[*parent_index_this-1].subtree_node_idx;  // might be null
}