679 cfunc, cdata, failed, root, |
679 cfunc, cdata, failed, root, |
680 loc_parent, loc_children, loc_last_child, |
680 loc_parent, loc_children, loc_last_child, |
681 loc_prev, loc_next); |
681 loc_prev, loc_next); |
682 } |
682 } |
683 |
683 |
684 static CxTreeIterator cx_tree_default_iterator( |
|
685 CxTree *tree, |
|
686 bool visit_on_exit |
|
687 ) { |
|
688 return cx_tree_iterator( |
|
689 tree->root, visit_on_exit, |
|
690 tree->loc_children, tree->loc_next |
|
691 ); |
|
692 } |
|
693 |
|
694 static CxTreeVisitor cx_tree_default_visitor(CxTree *tree) { |
|
695 return cx_tree_visitor(tree->root, tree->loc_children, tree->loc_next); |
|
696 } |
|
697 |
|
698 static int cx_tree_default_insert_element( |
684 static int cx_tree_default_insert_element( |
699 CxTree *tree, |
685 CxTree *tree, |
700 const void *data |
686 const void *data |
701 ) { |
687 ) { |
702 void *node; |
688 void *node; |
768 } |
754 } |
769 |
755 |
770 static cx_tree_class cx_tree_default_class = { |
756 static cx_tree_class cx_tree_default_class = { |
771 cx_tree_default_insert_element, |
757 cx_tree_default_insert_element, |
772 cx_tree_default_insert_many, |
758 cx_tree_default_insert_many, |
773 cx_tree_default_find, |
759 cx_tree_default_find |
774 cx_tree_default_iterator, |
|
775 cx_tree_default_visitor |
|
776 }; |
760 }; |
777 |
761 |
778 CxTree *cxTreeCreate( |
762 CxTree *cxTreeCreate( |
779 const CxAllocator *allocator, |
763 const CxAllocator *allocator, |
780 cx_tree_node_create_func create_func, |
764 cx_tree_node_create_func create_func, |
874 } |
858 } |
875 return visitor.depth; |
859 return visitor.depth; |
876 } |
860 } |
877 |
861 |
878 size_t cxTreeDepth(CxTree *tree) { |
862 size_t cxTreeDepth(CxTree *tree) { |
879 CxTreeVisitor visitor = tree->cl->visitor(tree); |
863 CxTreeVisitor visitor = cx_tree_visitor( |
|
864 tree->root, tree->loc_children, tree->loc_next |
|
865 ); |
880 while (cxIteratorValid(visitor)) { |
866 while (cxIteratorValid(visitor)) { |
881 cxIteratorNext(visitor); |
867 cxIteratorNext(visitor); |
882 } |
868 } |
883 return visitor.depth; |
869 return visitor.depth; |
884 } |
870 } |