blob: 3b7697b8c5a4abc2942515087b565efeae5cc078 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}
|