diff options
| author | Gustav Sörnäs <gusso230@student.liu.se> | 2020-08-17 19:34:09 +0200 |
|---|---|---|
| committer | Gustav Sörnäs <gusso230@student.liu.se> | 2020-08-17 19:34:09 +0200 |
| commit | 403ce5391e0fecc51bf50c86070ebc0e6d7e05af (patch) | |
| tree | 248c47b8687baa820d4803784c15a2a6d43405c4 /labb3/tsp/src/Node.h | |
| parent | c0a7e9ae20f29bb5d344cbb3923e0967034cadf1 (diff) | |
| download | tddd86-403ce5391e0fecc51bf50c86070ebc0e6d7e05af.tar.gz | |
add tsp codeL3
Diffstat (limited to 'labb3/tsp/src/Node.h')
| -rw-r--r-- | labb3/tsp/src/Node.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/labb3/tsp/src/Node.h b/labb3/tsp/src/Node.h new file mode 100644 index 0000000..f9908e4 --- /dev/null +++ b/labb3/tsp/src/Node.h @@ -0,0 +1,47 @@ +/* + * TDDD86 TSP + * This file contains the declaration of the Node structure. + * See Node.cpp for implementation of each member. + * Your code should work properly with an unmodified version of this file. + */ + +#ifndef NODE_H +#define NODE_H + +#include <iostream> +#include "Point.h" +using namespace std; + +/* + * Each Node structure represents a single node in a circular linked list + * used in a TSP tour. + */ +struct Node { + Point point; // this nodes point + Node* next; // pointer to next node in the list (nullptr if none) + + /* + * Constructs a new node storing the given point and next pointer. + */ + Node(Point p, Node* _next = nullptr); + + /* + * Returns a string representation of the Node for debugging, such as + * "Node{addr=0x7e83f4, point=(2.5, 3.5), next=0x43b2a0}". + * + * Note that the toString output includes the node's memory address, as well + * as the memory address where its next pointer points. + * + * Keep in mind that toString won't be called if you try to print a Node*. + * You must print the node itself. + */ + string toString() const; +}; + +/* + * Outputs the given node to the given output stream (e.g. cout) in the same + * format as returned by its toString member function. + */ +ostream& operator <<(ostream& out, const Node& node); + +#endif // END NODE_H |
