📄 graphnode.h
字号:
/* $Id: GraphNode.h,v 1.2 1997/02/02 01:31:02 matt Exp $ Generic graph node type. (c) Dec 95 Matt Phillips. */#ifndef _GRAPH_H#define _GRAPH_H#include <contain/Data.h>#include <contain/LinkedList.h>#include <contain/LinkedListIterExt.h>template <class T, class E>class GraphNodeImp{public: typedef GraphNodeImp<T, E> Node; typedef TypeILinkedList (Node) TargetList; typedef TypeILinkedListIterExt (Node) TargetListIterExt; GraphNodeImp (T &i) : data (i) {} GraphNodeImp (const GraphNodeImp<T, E> &n) : data (n.data), targets (n.targets) {} int operator == (const GraphNodeImp<T, E> &n) const {return ref () == n.ref ();} T &ref () const {return data.ref ();} TargetList &getTargets () {return targets;} int nTargets () const {return targets.nItems ();} void clearTargets () {targets.clear ();} void addTarget (GraphNodeImp<T, E> &t) {targets.add (t);} int clearTarget (const GraphNodeImp<T, E> &t); int hasTarget (const GraphNodeImp<T, E> &t) const;protected: E data; TargetList targets;};template <class T, class E>int GraphNodeImp<T, E>::hasTarget (const GraphNodeImp<T, E> &n) const{ for (TargetList::Iterator i (targets); i; i++) { if (i.ref () == n) return 1; } return 0;}template <class T, class E>int GraphNodeImp<T, E>::clearTarget (const GraphNodeImp<T, E> &n){ for (TargetListIterExt i (targets); i; i++) { if (i.ref () == n) { i.remove (); return 1; } } return 0;}#define TypeDGraphNode(T) GraphNodeImp<T, DContainerData<T> >#define TypeIGraphNode(T) GraphNodeImp<T, IContainerData<T, 0> >#define TypeIOGraphNode(T) GraphNodeImp<T, IContainerData<T, 1> >#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -