MCPcopy Create free account
hub / github.com/davisking/dlib / move_next

Method move_next

dlib/sequence/sequence_kernel_1.h:644–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642 typename mem_manager
643 >
644 bool sequence_kernel_1<T,mem_manager>::
645 move_next (
646 ) const
647 {
648 // if we haven't started iterating yet
649 if (at_start_)
650 {
651 at_start_ = false;
652 if (tree_size == 0)
653 {
654 return false;
655 }
656 else
657 {
658 // find the first element in the tree
659 current_element = tree_root;
660 node* temp = current_element->left;
661 while (temp != 0)
662 {
663 push(current_element);
664 current_element = temp;
665 temp = current_element->left;
666 }
667 return true;
668 }
669 }
670 else
671 {
672 if (current_element == 0)
673 {
674 return false;
675 }
676 else
677 {
678 node* temp;
679 bool went_up; // true if we went up the tree from a child node to parent
680 bool from_left = false; // true if we went up and were coming from a left child node
681 // find the next element in the tree
682 if (current_element->right != 0)
683 {
684 // go right and down
685 temp = current_element;
686 push(current_element);
687 current_element = temp->right;
688 went_up = false;
689 }
690 else
691 {
692 // go up to the parent if we can
693 if (current_element == tree_root)
694 {
695 // in this case we have iterated over all the element of the tree
696 current_element = 0;
697 return false;
698 }
699 went_up = true;
700 node* parent = pop();
701

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected