struct Node *traverse_backward(struct Node *head) { if(head==NULL) return head; traverse_backward(head->next); printf("%d",head->data); return head; }
Fl_ToggleNode* Fl_ToggleTree::selection(int i) { int backwards = 0; if (selection_current_ == 0) { selection_current_ = traverse_start(); selection_i_ = 0; } else { traverse_start(selection_current_); if (i > selection_i_) { selection_current_ = traverse_forward(); selection_i_ ++; } else if (i < selection_i_) { selection_current_ = traverse_backward(); selection_i_ --; backwards = 1; } } if (backwards) { while (selection_current_) { //printf("traversed bw to:%s\n",selection_current_->label()); if (selection_current_->selected_) { if (i == selection_i_) { return selection_current_; } selection_i_ --; } selection_current_ = traverse_backward(); } } else { while (selection_current_) { if (selection_current_->selected_) { if (i == selection_i_) { return selection_current_; } selection_i_ ++; } selection_current_ = traverse_forward(); } } return 0; }