src/tree.c

changeset 893
0a2b328f5b91
parent 890
54565fd74e74
child 901
109567325fe7
equal deleted inserted replaced
892:6ebf6fdfbc2c 893:0a2b328f5b91
539 539
540 unsigned int cx_tree_add_look_around_depth = 3; 540 unsigned int cx_tree_add_look_around_depth = 3;
541 541
542 size_t cx_tree_add_iter( 542 size_t cx_tree_add_iter(
543 struct cx_iterator_base_s *iter, 543 struct cx_iterator_base_s *iter,
544 size_t num,
544 cx_tree_search_func sfunc, 545 cx_tree_search_func sfunc,
545 cx_tree_node_create_func cfunc, 546 cx_tree_node_create_func cfunc,
546 void *cdata, 547 void *cdata,
547 void **failed, 548 void **failed,
548 void *root, 549 void *root,
560 561
561 size_t processed = 0; 562 size_t processed = 0;
562 void *current_node = root; 563 void *current_node = root;
563 const void *elem; 564 const void *elem;
564 565
565 for (void **eptr; 566 for (void **eptr; processed < num &&
566 iter->valid(iter) && (eptr = iter->current(iter)) != NULL; 567 iter->valid(iter) && (eptr = iter->current(iter)) != NULL;
567 iter->next(iter)) { 568 iter->next(iter)) {
568 elem = *eptr; 569 elem = *eptr;
569 570
570 // create the new node 571 // create the new node
657 } 658 }
658 } 659 }
659 660
660 // otherwise, create iterator and hand over to other function 661 // otherwise, create iterator and hand over to other function
661 CxIterator iter = cxIterator(src, elem_size, num); 662 CxIterator iter = cxIterator(src, elem_size, num);
662 return cx_tree_add_iter(cxIteratorRef(iter), sfunc, 663 return cx_tree_add_iter(cxIteratorRef(iter), num, sfunc,
663 cfunc, cdata, failed, root, 664 cfunc, cdata, failed, root,
664 loc_parent, loc_children, loc_last_child, 665 loc_parent, loc_children, loc_last_child,
665 loc_prev, loc_next); 666 loc_prev, loc_next);
666 } 667 }
667 668

mercurial