예제 #1
0
bool
tree_iterator_first(void* Iterator)
{
    ASSERT(Iterator != NULL);
    tree_iterator* iterator = Iterator;
    ASSERT(iterator->tree != NULL);
    if (iterator->tree->root) {
	iterator->node = tree_node_min(iterator->tree->root);
	return true;
    }
    return false;
}
예제 #2
0
bool
tr_itor_first(tr_itor* itor)
{
    ASSERT(itor != NULL);

    if (itor->tree->root) {
	itor->node = tree_node_min(itor->tree->root);
	return true;
    } else {
	itor->node = NULL;
	return false;
    }
}
예제 #3
0
void*
tree_node_next(void* Node)
{
    tree_node* node = Node;
    ASSERT(node != NULL);
    if (node->rlink) {
	return tree_node_min(node->rlink);
    }
    tree_node* parent = node->parent;
    while (parent && parent->rlink == node) {
	node = parent;
	parent = parent->parent;
    }
    return parent;
}
예제 #4
0
파일: sp_tree.c 프로젝트: SavOK/libdict
size_t
sp_tree_traverse(sp_tree* tree, dict_visit_func visit)
{
    ASSERT(tree != NULL);
    ASSERT(visit != NULL);

    size_t count = 0;
    if (tree->root) {
	sp_node* node = tree_node_min(tree->root);
	do {
	    ++count;
	    if (!visit(node->key, node->datum))
		break;
	    node = tree_node_next(node);
	} while (node);
    }
    return count;
}