shape_doc 0.1
GraphDfsIter< T > Class Template Reference

Iterator for DFS traversal. More...

#include <graph.hpp>

List of all members.

Public Member Functions


Detailed Description

template<class T>
class mmx::shape::GraphDfsIter< T >

Iterator for DFS traversal.

Definition at line 197 of file graph.hpp.


Constructor & Destructor Documentation

GraphDfsIter ( const Graph< T >  s) [inline]

Definition at line 205 of file graph.hpp.

    {
      g = &s;
    }

Member Function Documentation

gNode<T>* currentItem ( ) [inline]

Definition at line 298 of file graph.hpp.

    {
      return current;
    }
void first ( ) [inline]

Definition at line 210 of file graph.hpp.

References gNode< T >::status().

    {
      current = g->head;
      next_start=current->vlist;
      
      gNode<T>* t=current;
      while(t!=NULL)// Mark all as not visited
      {
        t->status(-1);
        t=t->vlist;
      }
      current->status(0);
    }
bool isDone ( ) [inline]

Definition at line 293 of file graph.hpp.

    {
      return current == NULL;
    }
bool isLast ( ) [inline]

Definition at line 224 of file graph.hpp.

    {

      if ( q.empty() )
      {
        
        while( next_start!=NULL)
        {
          if ( next_start->status()==-1) 
          {
            next_start->status(0);
            q.push(next_start); 
            next_start=next_start->vlist;
            break;
          }
          next_start=next_start->vlist;
        }
      }

        if (next_start==NULL)
          return true;
        else
          return false;
    }
void next ( ) [inline]

Definition at line 249 of file graph.hpp.

    {
      
      if ( q.empty() )
      {
        
        while( next_start!=NULL)
        {
          if ( next_start->status()==-1) 
          {
            next_start->status(0);
            q.push(next_start); 
            next_start=next_start->vlist;
            break;
          }
          next_start=next_start->vlist;
        }
        
        if (next_start==NULL)// Finished
        {
          current= NULL; //isDone
          return;
        }
        
      }
      
      // q not empty
      current= q.top();
      q.pop();
      
      gNode<T>* t=current;       
      while(t->next!=NULL)
      {
        if ( t->next->status() == -1 )
        {
          t->next->status(0); // mark as visited 
          q.push(t->next->start); 
        }
        t=t->next;
      }
      
      return;
    }

The documentation for this class was generated from the following file: