src/cx/tree.h

changeset 914
7da30512efc4
parent 913
72db8e42b95e
equal deleted inserted replaced
913:72db8e42b95e 914:7da30512efc4
839 void *(*find)( 839 void *(*find)(
840 struct cx_tree_s *tree, 840 struct cx_tree_s *tree,
841 const void *subtree, 841 const void *subtree,
842 const void *data 842 const void *data
843 ); 843 );
844
845 /**
846 * Member function for creating an iterator for the tree.
847 */
848 CxTreeIterator (*iterator)(
849 struct cx_tree_s *tree,
850 bool visit_on_exit
851 );
852
853 /**
854 * Member function for creating a visitor for the tree.
855 */
856 CxTreeVisitor (*visitor)(struct cx_tree_s *tree);
857 }; 844 };
858 845
859 /** 846 /**
860 * Common type for all tree implementations. 847 * Common type for all tree implementations.
861 */ 848 */
1111 __attribute__((__nonnull__, __warn_unused_result__)) 1098 __attribute__((__nonnull__, __warn_unused_result__))
1112 static inline CxTreeIterator cxTreeIterator( 1099 static inline CxTreeIterator cxTreeIterator(
1113 CxTree *tree, 1100 CxTree *tree,
1114 bool visit_on_exit 1101 bool visit_on_exit
1115 ) { 1102 ) {
1116 return tree->cl->iterator(tree, visit_on_exit); 1103 return cx_tree_iterator(
1104 tree->root, visit_on_exit,
1105 tree->loc_children, tree->loc_next
1106 );
1117 } 1107 }
1118 1108
1119 /** 1109 /**
1120 * Creates a breadth-first iterator for the specified tree. 1110 * Creates a breadth-first iterator for the specified tree.
1121 * 1111 *
1123 * @return a tree visitor (a.k.a. breadth-first iterator) 1113 * @return a tree visitor (a.k.a. breadth-first iterator)
1124 * @see cxTreeIterator() 1114 * @see cxTreeIterator()
1125 */ 1115 */
1126 __attribute__((__nonnull__, __warn_unused_result__)) 1116 __attribute__((__nonnull__, __warn_unused_result__))
1127 static inline CxTreeVisitor cxTreeVisitor(CxTree *tree) { 1117 static inline CxTreeVisitor cxTreeVisitor(CxTree *tree) {
1128 return tree->cl->visitor(tree); 1118 return cx_tree_visitor(
1119 tree->root, tree->loc_children, tree->loc_next
1120 );
1129 } 1121 }
1130 1122
1131 /** 1123 /**
1132 * Adds a new node to the tree. 1124 * Adds a new node to the tree.
1133 * 1125 *

mercurial