📄 bigraphvertex.h
字号:
// file: $isip/class/dstr/BiGraphVertex/BiGraphVertex.h// version: $Id: BiGraphVertex.h,v 1.7 2003/03/06 15:57:42 alphonso Exp $//// make sure definitions are only made once//#ifndef ISIP_BIGRAPH_VERTEX#define ISIP_BIGRAPH_VERTEX// isip include files//#ifndef ISIP_DOUBLE_LINKED_LIST#include <DoubleLinkedList.h>#endif#ifndef ISIP_MEMORY_MANAGER#include <MemoryManager.h>#endif#ifndef ISIP_STRING#include <String.h>#endif// forward class definitions:// we must define the BiGraph class and the BiGraphArc class here first because// the header files might be short-circuited by the ifndef.//template<class TObject> class BiGraph;template<class TObject> class BiGraphArc;// BiGraphVertex: a generic BiGraphVertex. the main purpose of a vertex is// to hold a list of arcs originating from the given vertex.//template<class TObject>class BiGraphVertex : public Node<TObject> { //--------------------------------------------------------------------------- // // public constants // //---------------------------------------------------------------------------public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; //---------------------------------------- // // default values and arguments // //---------------------------------------- // default values // // default arguments to methods // //---------------------------------------- // // error codes // //---------------------------------------- static const long ERR = 41100; static const long ERR_NULLD = 41101; static const long ERR_NOPAR = 41102; //--------------------------------------------------------------------------- // // protected data // //---------------------------------------------------------------------------protected: // adjacency list manipulation methods // DoubleLinkedList< BiGraphArc<TObject> > parents_d; DoubleLinkedList< BiGraphArc<TObject> > children_d; // what BiGraph does this vertex belong to // BiGraph<TObject>* parent_graph_d; // define the memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //---------------------------------------------------------------------------public: // static methods // static const String& name(); // this class doesn't have a diagnose method, its functionality is // tested in BiGraph::diagnose // // debug methods: // setDebug is inherited from the DoubleLinkedList template class // boolean debug(const unichar* message) const; // method: destructor // ~BiGraphVertex() { removeAllArcsChild(); removeAllArcsParent(); } // method: default constructor // BiGraphVertex() { parent_graph_d = (BiGraph<TObject>*)NULL; setAllocationModeChild(USER); setAllocationModeParent(USER); } // method: copy constructor // BiGraphVertex(const BiGraphVertex<TObject>& arg) { parent_graph_d = (BiGraph<TObject>*)NULL; setAllocationModeChild(USER); setAllocationModeParent(USER); assign(arg); } // assign methods // boolean assign(const BiGraphVertex<TObject>& copy_vertex); // method: operator= // BiGraphVertex<TObject>& operator=(const BiGraphVertex<TObject>& arg) { assign(arg); return *this; } // i/o methods: // these methods are not needed since BiGraph takes care of it's own I/O. // // method: eq // determines if the contents of the vertex are equivalent. // adjacency lists & weights are ignored. // boolean eq(const BiGraphVertex<TObject>& arg) const { return Node<TObject>::eq(arg); } // method: new // void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static boolean setGrowSize(long grow_size) { return (mgr_d.setGrow(grow_size)); } // other memory management methods: // boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // parent bigraph manipulation methods // //--------------------------------------------------------------------------- // method: setParentGraph // boolean setParentGraph(BiGraph<TObject>* parent) { parent_graph_d = parent; return true; } // method: getParentGraph // BiGraph<TObject>* getParentGraph() const { return parent_graph_d; } //--------------------------------------------------------------------------- // // class-specific public methods: // vertex manipulation methods // //--------------------------------------------------------------------------- // insert/remove a vertex to/from the adjacency list: // these methods assume that the user is taking care of updating the // parent BiGraphs, end vertices, etc. // boolean insertArcChild(BiGraphVertex<TObject>* vertex, double weight = BiGraphArc<TObject>::DEF_WEIGHT, boolean is_epsilon = BiGraphArc<TObject>::DEF_EPSILON); boolean insertArcParent(BiGraphVertex<TObject>* vertex, double weight = BiGraphArc<TObject>::DEF_WEIGHT, boolean is_epsilon = BiGraphArc<TObject>::DEF_EPSILON); boolean insertArcChild(BiGraphVertex<TObject>* vertex, boolean is_epsilon = BiGraphArc<TObject>::DEF_EPSILON); boolean insertArcParent(BiGraphVertex<TObject>* vertex, boolean is_epsilon = BiGraphArc<TObject>::DEF_EPSILON); boolean removeArcChild(BiGraphVertex<TObject>* vertex); boolean removeArcParent(BiGraphVertex<TObject>* vertex); boolean removeArcChild(); boolean removeArcParent(); boolean removeAllArcsChild(); boolean removeAllArcsParent(); // is this vertex adjacent? // boolean isAdjacentChild(BiGraphVertex<TObject>* vertex) const; boolean isAdjacentParent(BiGraphVertex<TObject>* vertex) const; // method: isStart // boolean isStart() const { if (parent_graph_d == (BiGraph<TObject>*)NULL) { return Error::handle(name(), L"isStart - undefined parent", Error::ARG, __FILE__, __LINE__); } return (this == parent_graph_d->getStart()); } // method: isTerm // boolean isTerm() const { if (parent_graph_d == (BiGraph<TObject>*)NULL) { return Error::handle(name(), L"isTerm - undefined parent", Error::ARG, __FILE__, __LINE__); } return (this == parent_graph_d->getTerm()); } //--------------------------------------------------------------------------- // // class-specific public methods: // vertex comparison methods // //--------------------------------------------------------------------------- // compares the siblings of the two vertices and arc weights to see if // the two vertices has a similar structure // boolean compareVertices(const BiGraphVertex<TObject>& compare_vertex_a) const; //--------------------------------------------------------------------------- // // class-specific public methods: // adjacency list retrieval methods // //--------------------------------------------------------------------------- // method: getParents // DoubleLinkedList< BiGraphArc<TObject> >* getParents() { return &parents_d; } // method: getChildren // DoubleLinkedList< BiGraphArc<TObject> >* getChildren() { return &children_d; } //--------------------------------------------------------------------------- // // class-specific public methods: // adjacency list positioning methods // //-------------------------------------------------------------------------- // method: gotoFirstChild // boolean gotoFirstChild() { return children_d.gotoFirst(); } // method: gotoLastChild // boolean gotoLastChild() { return children_d.gotoLast(); } // method: gotoNextChild // boolean gotoNextChild() { return children_d.gotoNext(); } // method: gotoPrevChild // boolean gotoPrevChild() { return children_d.gotoPrev(); } // method: gotoMarkChild // boolean gotoMarkChild() { return children_d.gotoMark(); } // method: gotoPositionChild // boolean gotoPositionChild(long arg) { return children_d.gotoPosition(arg); } // method: getPositionChild // long getPositionChild() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> > & > (children_d).getPosition(); } // method: gotoFirstParent // boolean gotoFirstParent() { return parents_d.gotoFirst(); } // method: gotoLastParent // boolean gotoLastParent() { return parents_d.gotoLast(); } // method: gotoNextParent // boolean gotoNextParent() { return parents_d.gotoNext(); } // method: gotoPrevParent // boolean gotoPrevParent() { return parents_d.gotoPrev(); } // method: gotoMarkParent // boolean gotoMarkParent() { return parents_d.gotoMark(); } // method: gotoPositionParent // boolean gotoPositionParent(long arg) { return parents_d.gotoPosition(arg); } // method: getPositionParent // long getPositionParent() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (parents_d).getPosition(); } //--------------------------------------------------------------------------- // // class-specific public methods: // adjacency list marking methods // //-------------------------------------------------------------------------- // method: markIsSetChild // boolean markIsSetChild() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (children_d).markIsSet(); } // method: isMarkedElementChild // boolean isMarkedElementChild() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (children_d).isMarkedElement(); } // method: clearMarkChild // boolean clearMarkChild() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (children_d).clearMark(); } // method: setMarkChild // boolean setMarkChild() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (children_d).setMark(); } // method: markIsSetParent // boolean markIsSetParent() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (parents_d).markIsSet(); } // method: isMarkedElementParent // boolean isMarkedElementParent() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (parents_d).isMarkedElement(); } // method: clearMarkParent // boolean clearMarkParent() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (parents_d).clearMark(); } // method: setMarkParent // boolean setMarkParent() const { return const_cast<DoubleLinkedList<BiGraphArc<TObject> >& > (parents_d).setMark(); } //--------------------------------------------------------------------------- // // class-specific public methods: // adjacency list access methods // //-------------------------------------------------------------------------- // method: getFirstChild // BiGraphArc<TObject>* getFirstChild() { return children_d.getFirst(); } // method: getLastChild // BiGraphArc<TObject>* getLastChild() { return children_d.getLast(); } // method: getNextChild // BiGraphArc<TObject>* getNextChild() { return children_d.getNext(); } // method: getPrevChild // BiGraphArc<TObject>* getPrevChild() { return children_d.getPrev(); } // method: getMarkChild // BiGraphArc<TObject>* getMarkChild() { return children_d.getMark(); } // method: getCurrChild // BiGraphArc<TObject>* getCurrChild() { return children_d.getCurr(); } // method: getFirstChild
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -