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 201 of file graph.hpp.


Constructor & Destructor Documentation

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

Definition at line 209 of file graph.hpp.

00210     {
00211       g = &s;
00212     }


Member Function Documentation

gNode<T>* currentItem (  )  [inline]

Definition at line 300 of file graph.hpp.

Referenced by voronoi2dimpl< C, V >::run(), and voronoi2d< C, V >::run().

00301     {
00302       return current;
00303     }

void first (  )  [inline]

Definition at line 214 of file graph.hpp.

References gNode< T >::status().

Referenced by voronoi2dimpl< C, V >::run(), and voronoi2d< C, V >::run().

00215     {
00216       current = g->head;
00217       next_start=current->vlist;
00218       
00219       gNode<T>* t=current;
00220       while(t!=NULL)// Mark all as not visited
00221       {
00222         t->status(-1);
00223         t=t->vlist;
00224       }
00225       current->status(0);
00226     }

bool isDone (  )  [inline]

Definition at line 295 of file graph.hpp.

Referenced by voronoi2dimpl< C, V >::run(), and voronoi2d< C, V >::run().

00296     {
00297       return current == NULL;
00298     }

bool isLast (  )  [inline]

Definition at line 228 of file graph.hpp.

00229     {
00230       if ( !q.empty() )
00231           return false;
00232 
00233       while( next_start!=NULL)
00234       {
00235         if ( next_start->status()==-1) 
00236         {
00237           next_start->status(0);
00238           q.push(next_start); 
00239           next_start=next_start->vlist;
00240           break;
00241         }
00242         next_start=next_start->vlist;
00243       }
00244       
00245       if (q.empty() && next_start==NULL)
00246         return true;
00247       else
00248         return false;
00249     }

void next (  )  [inline]

Definition at line 251 of file graph.hpp.

Referenced by voronoi2dimpl< C, V >::run(), and voronoi2d< C, V >::run().

00252     {
00253       
00254       if ( q.empty() )
00255       {
00256         
00257         while( next_start!=NULL)
00258         {
00259           if ( next_start->status()==-1) 
00260           {
00261             next_start->status(0);
00262             q.push(next_start); 
00263             next_start=next_start->vlist;
00264             break;
00265           }
00266           next_start=next_start->vlist;
00267         }
00268         
00269         if (q.empty() && next_start==NULL)// Finished
00270         {
00271           current= NULL; //isDone
00272           return;
00273         }
00274         
00275       }
00276       
00277       // q not empty
00278       current= q.top();
00279       q.pop();
00280       
00281       gNode<T>* t=current;       
00282       while(t->next!=NULL)
00283       {
00284         if ( t->next->status() == -1 )
00285         {
00286           t->next->status(0); // mark as visited 
00287           q.push(t->next->start); 
00288         }
00289         t=t->next;
00290       }
00291       
00292       return;
00293     }


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

Generated on 6 Dec 2012 for shape by  doxygen 1.6.1