delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/06/10:17:01

Message-ID: <35794D51.D49BABED@BigPond.com>
Date: Sun, 07 Jun 1998 00:08:18 +1000
From: Dominique Louis <Dominique_Louis AT BigPond DOT com>
Reply-To: Dominique_Louis AT BigPond DOT com
Organization: Savage Software Solutions
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Help I'm Looping ...
NNTP-Posting-Host: 139.134.57.236
Lines: 44
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi all,
I've spent the last few hours looking at the following code and can't
work out why it's looping.
Basically the function returns a list of all Nodes that are reachable
from a particular Node.
I don't think the fact that I'm using templates has anything to do with
it, but maybe it has ( that's why I'm posting this message, I'm not sure
of anything right now ).
If you've got a spare 5 minutes please check it for me.
The code is as follows....

list< Node > reachable( Node reachVertice )
    {
      list< Node > x, x1;
      list< Edge > :: iterator i;

      cout << "reachable";
      for( i = EdgeList.begin( ); i != EdgeList.end( ); i++ )
      {
        if( ( i->getFrom( ) == reachVertice )  );
        {
          x.push_back( i->getTo( ) );
          x1 = reachable( i->getTo( ) );
          if( !x1.empty( ) )
          {
            x.splice( x.end( ), x1 );
            x.sort( );
            x.unique( );
          }
        }
      }
      return x;
    }


thanks in advance,


Dominique Louis.
===========================================================
To Do Nothing is to Collaborate with the oppressor!
===========================================================


- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019