Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

nci/suif/suif2b/extratypes/sgraph/sgraph_iter_impl.h

Go to the documentation of this file.
00001 #ifndef SGRAPH_ITER_IMPL_H
00002 #define SGRAPH_ITER_IMPL_H
00003 
00004 #include "sgraph_iter.h"
00005 
00006 /*
00007  * build an iterator over an edge list
00008  */
00009 class SGraphNodeListIter : public SGraphNodeIter {
00010   SGraphNodeList * _list;
00011   bool _owned; // If owned, delete it afterwards
00012   SGraphNodeList::iterator _iter;
00013 public:
00014   SGraphNodeListIter();
00015   SGraphNodeListIter(const SGraphNodeListIter &other);
00016   SGraphNodeListIter &operator=(const SGraphNodeListIter &other);
00017   SGraphNodeListIter(SGraphNodeList *list, bool owned);
00018   void reset(SGraphNodeList* list, bool owned);
00019   void reset();
00020   virtual bool done() const;
00021   virtual SGraphNode get() const;
00022   virtual void increment();
00023   virtual SGraphNode step();
00024   virtual SGraphNodeIter *clone() const;
00025 };
00026 
00027 
00028 
00029 /*
00030  * build an iterator over an edge list
00031  */
00032 class SGraphEdgeListIter : public SGraphEdgeIter {
00033   SGraphEdgeList *_list;
00034   bool _owned; // If owned, delete it afterwards
00035   SGraphEdgeList::iterator _iter;
00036 public:
00037   SGraphEdgeListIter();
00038   SGraphEdgeListIter(const SGraphEdgeListIter &other);
00039   SGraphEdgeListIter &operator=(const SGraphEdgeListIter &other);
00040   SGraphEdgeListIter(SGraphEdgeList *list, bool owned);
00041   void reset(SGraphEdgeList *list, bool owned);
00042   void reset();
00043   virtual bool done() const;
00044   virtual SGraphEdge get() const;
00045   virtual void increment();
00046   virtual SGraphEdge step();
00047   virtual SGraphEdgeIter *clone() const;
00048 };
00049 
00050 
00051 /*
00052  *
00053  * Filters
00054  * 
00055  * implements filters that choose among nodes
00056  */
00057 
00058 
00059 // This is a simple example of a filter to filter only
00060 // the nodes that are in a graph.
00061 class SGraphNodeGraphFilter : public SGraphNodeFilter {
00062   const SGraph *_the_sgraph;
00063   SGraphNodeGraphFilter(const SGraphNodeGraphFilter &) :
00064     _the_sgraph(NULL) {}
00065   SGraphNodeGraphFilter &operator=(const SGraphNodeGraphFilter &other) {
00066     _the_sgraph = other._the_sgraph; return *this;}
00067 public:
00068   SGraphNodeGraphFilter(const SGraph *the_sgraph) :
00069     _the_sgraph(the_sgraph) {}
00070   virtual bool is_node_member(SGraphNode node) const {
00071     return(_the_sgraph->is_node_member(node)); }
00072 };
00073 
00074 class SGraphFilteredNodeIter : public SGraphNodeIter {
00075   SNodeIter _base_iter;
00076   SGraphNodeFilter *_filter;
00077   bool _owned;
00078   size_t _last;
00079   bool _done;
00080 public:
00081   SGraphFilteredNodeIter();
00082   SGraphFilteredNodeIter(const SGraphFilteredNodeIter &other);
00083   SGraphFilteredNodeIter(SNodeIter base_iter,
00084                          SGraphNodeFilter *filter,
00085                          bool owned);
00086   SGraphFilteredNodeIter &operator=(const SGraphFilteredNodeIter &other);
00087   void reset(SNodeIter base_iter, SGraphNodeFilter *filter,
00088              bool owned);
00089   virtual void reset();
00090   virtual bool done() const;
00091   virtual SGraphNode get() const;
00092   virtual void increment();
00093   virtual SGraphNodeIter *clone() const;
00094 };
00095 
00096 #endif /* SGRAPH_ITER_IMPL_H */

Generated at Mon Jul 31 13:41:49 2000 for NCI SUIF by doxygen 1.1.2 written by Dimitri van Heesch, © 1997-2000