summaryrefslogtreecommitdiffstats
path: root/labb3/tsp/src/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'labb3/tsp/src/Node.cpp')
-rw-r--r--labb3/tsp/src/Node.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/labb3/tsp/src/Node.cpp b/labb3/tsp/src/Node.cpp
new file mode 100644
index 0000000..3b7697b
--- /dev/null
+++ b/labb3/tsp/src/Node.cpp
@@ -0,0 +1,32 @@
+/*
+ * TDDD86 TSP
+ * This file contains the implementation of the Node structure.
+ * See Node.h for comments about each member.
+ * Your code should work properly with an unmodified version of this file.
+ */
+
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+#include "Node.h"
+
+Node::Node(Point p, Node* _next)
+ : point(p.x, p.y), next(_next) {}
+
+string Node::toString() const {
+ stringstream out;
+ out << "Node{addr=" << ((void*) this);
+ out << ", point=" << point;
+ if (next != nullptr) {
+ out << ", next=" << ((void*) next);
+ } else {
+ out << ", next=nullptr";
+ }
+ out << "}";
+ return out.str();
+}
+
+ostream& operator <<(ostream& out, const Node& node) {
+ out << node.toString();
+ return out;
+}