gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] sgf/sgfnode.c possible error


From: Paul Pogonyshev
Subject: Re: [gnugo-devel] sgf/sgfnode.c possible error
Date: Wed, 15 Sep 2004 11:54:05 -0200
User-agent: KMail/1.4.3

Dmitri Koulikov wrote:

>   I've found a controversial usage of 'parent' link of SGFNode in
> functions sgfPrev and sgfAddChild by one side and sgfStartVariant and
> sgfStartVariantFirst by the other. The first ones use it always as a
> pointer to the parent node while the latter use it to show to the
> previous sibling if it exist and to the parent if not.
>   Where is the truth?

I cannot understand what you mean.  The structure of an SGF tree
inside GNU Go looks like this:

  parent node
       |
 (first) child --> next (child) --> next (child) --> NULL

So, the childs form a single-linked list.  Since you cannot go
directly backwards in a single-linked list, you need to start
from the list beginning and skip forward.  In other words,
previous node can be found like this:

  if (node->parent) {
    previous = node->parent->child;
    while (previous->next != node)
      previous = previous->next;
  }

Paul





reply via email to

[Prev in Thread] Current Thread [Next in Thread]