summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp')
-rw-r--r--src/boost/libs/yap/example/autodiff_library/EdgeSet.cpp76
1 files changed, 76 insertions, 0 deletions
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 <sstream>
+
+using namespace std;
+namespace AutoDiff {
+
+EdgeSet::EdgeSet() {
+ // TODO Auto-generated constructor stub
+
+}
+
+EdgeSet::~EdgeSet() {
+ edges.clear();
+}
+
+bool EdgeSet::containsEdge(Edge& e)
+{
+ list<Edge>::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<Edge>::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<Edge>::iterator it = edges.begin();
+ for(;it!=edges.end();it++)
+ {
+ oss<<(*it).toString()<<endl;
+ }
+ return oss.str();
+}
+
+} /* namespace AutoDiff */