#ifndef BGBASEITER_HEADER #define BGBASEITER_HEADER 1 /////////////////////////////////////////////////////////////// //! file="amma/Contain/Branch/BGBaseIter.hh" //! lib=Branch //! userlevel=Default //! author="" //! docentry="Containers.Graphs.Branching" //! date="23/03/97" // Contain/Branch/BGBaseIter.hh 26/2/97 By Charles Galambos //! rcsid="$Id: BGBaseIter.hh,v 1.6 1999/01/28 14:13:18 eep1rr Exp $" #include "amma/BGraphBase.hh" class BGraphBaseAdjIterC : public BGraphTypesC { public: inline BGraphBaseAdjIterC(BGraphNodeBaseC &Node,Dir Way); // Constructor. inline BGraphBaseAdjIterC(const BGraphBaseAdjIterC &Oth); // Copy constructor. inline void Next(); // Goto next. inline BooleanT IsElm() const; // At valid element ? inline BGraphEdgeBaseC &Edge() { return *EdgeP; } // Access edge. inline const BGraphEdgeBaseC &Edge() const { return *EdgeP; } // Access edge. NodeHandleT FarNodeH() const { return EdgeP->Node(!Way); } // Get node handle at other end. NodeHandleT NearNodeH() const { return EdgeP->Node(Way); } // Get node handle for this end. void Dump(void); // Dump to stdout. private: BGraphEdgeBaseC *EdgeP; Dir Way; }; class BGraphBaseNodeIterC : public BGraphTypesC { public: inline BGraphBaseNodeIterC(BGraphBaseC &nGraph); // Constructor. inline BGraphBaseNodeIterC(BGraphBaseC &nGraph,NodeHandleT H); // Constructor. inline BGraphBaseNodeIterC(const BGraphBaseNodeIterC &Oth); // Copy Constructor. void First() { i = 0; } // Goto first node. void Next() { i++; } // Goto next node. BooleanT IsElm() const { return i < G.NoNodes(); } // At a valid element ? BGraphNodeBaseC &Node() { return G.Node(i); } // Get Node. NodeHandleT NodeH() const { return i; } // Node handle. void Dump(void); // Dump to stdout. private: BGraphBaseC G; // Graph. IndexT i; }; ////////////////////////////////////////// inline BGraphBaseAdjIterC::BGraphBaseAdjIterC(BGraphNodeBaseC &Node, BGraphTypesC::Dir nWay) : Way(nWay) { EdgeP = static_cast (Node.Edges(nWay)); } inline BGraphBaseAdjIterC::BGraphBaseAdjIterC(const BGraphBaseAdjIterC &Oth) : EdgeP(Oth.EdgeP), Way(Oth.Way) {} inline void BGraphBaseAdjIterC::Next() { EdgeP = &EdgeP->NextEdge(Way); } inline BooleanT BGraphBaseAdjIterC::IsElm() const { return EdgeP != NULL; } /////////////////////////////////////////////// inline BGraphBaseNodeIterC::BGraphBaseNodeIterC(BGraphBaseC &nG) : G(nG) { First(); } inline BGraphBaseNodeIterC::BGraphBaseNodeIterC(BGraphBaseC &nGraph, NodeHandleT Nd) : G(nGraph), i(Nd) {} inline BGraphBaseNodeIterC::BGraphBaseNodeIterC(const BGraphBaseNodeIterC &Oth) : G(Oth.G), i(Oth.i) {} #endif