Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CF: ideas for next experiments



Kjetil Torgrim Homme wrote:
> 
> [David Andrew Michael Noelle]
> 
> >       IMHO, A binary search tree with a parent pointer would be the
> >   ideal structure for this.
> 
> What does this look like?  I don't understand how you can reconcile a
> binary tree with a next->next->next traverse method with only one
> pointer added.

node *BST_next(BST *tree, node *here) {
  node *temp;

  if (here == NULL) {
    temp = tree->head;
    while (temp->left != NULL) {
      temp = temp->left;
    }
  } else {
    temp = here;
    if (here->right != NULL) {
      temp = here->right;
      while (temp->left != NULL) {
        temp = temp->left;
      }
    } else {
      if (here->up == NULL) {
        return (NULL);
      } else {
        if (here->parent->left == here) {
          temp = here->parent;
        } else {
	  while (temp->parent != NULL) {
	    temp = temp->parent;
	    if (temp->parent->right == temp) {
              break;
            }
          if (temp->parent == NULL) {
	    temp = NULL;
	  }
	}
      }
    }
  }
  return (temp);
}

-- 
            -Dave Noelle,                 dave@Straylight.org
            -the Villa Straylight,  http://www.straylight.org
Coalition Against Unsolicited Commercial Email  ==  http://www.cauce.com

Disclaimer: Disciples of E(vi)L may receive guidance in alt.religion.emacs.
GNU Emacs is The One True Editor.  The $PATH to redemption is /util/gnu/bin.
U.C.L.A. doesn't share my opinions; even Emacs can't make life that good.

Quote of the Day:
"The fastest way to accelerate a Macintosh is 9.8 m/s^2"
-
[you can put yourself on the announcement list only or unsubscribe altogether
by sending an email stating your wishes to crossfire-request@ifi.uio.no]