From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../libs/yap/example/autodiff_library/EdgeSet.cpp | 76 ++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp (limited to 'src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp') diff --git a/src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp b/src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp new file mode 100644 index 000000000..20e16132a --- /dev/null +++ b/src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp @@ -0,0 +1,76 @@ +/* + * EdgeSet.cpp + * + * Created on: 12 Nov 2013 + * Author: s0965328 + */ + +#include "EdgeSet.h" +#include "Edge.h" +#include + +using namespace std; +namespace AutoDiff { + +EdgeSet::EdgeSet() { + // TODO Auto-generated constructor stub + +} + +EdgeSet::~EdgeSet() { + edges.clear(); +} + +bool EdgeSet::containsEdge(Edge& e) +{ + list::iterator it = edges.begin(); + for(;it!= edges.end();it++){ + Edge eit = *it; + if(eit.isEqual(e)) + { + return true; + } + } + return false; +} + +void EdgeSet::insertEdge(Edge& e) { + if(!containsEdge(e)){ + edges.push_front(e); + } +} + +void EdgeSet::clear() { + edges.clear(); +} + +unsigned int EdgeSet::size(){ + return edges.size(); +} + +unsigned int EdgeSet::numSelfEdges(){ + unsigned int diag = 0; + list::iterator it = edges.begin(); + for(;it!=edges.end();it++) + { + Edge eit = *it; + if(eit.a == eit.b) + { + diag++; + } + } + return diag; +} + +string EdgeSet::toString() +{ + ostringstream oss; + list::iterator it = edges.begin(); + for(;it!=edges.end();it++) + { + oss<<(*it).toString()<