diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2020-12-03 17:11:43 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2020-12-08 10:21:07 +0100 |
| commit | 0c39051ba80f04b1177833a006f2d442a7170b56 (patch) | |
| tree | 9e657946a061b5b305f9cf75634db7b37e979eb3 /labb8/src/types.h | |
| parent | 7b7f6808a7b2db2ed21103767434c1445f7815c2 (diff) | |
| download | tddd86-0c39051ba80f04b1177833a006f2d442a7170b56.tar.gz | |
add initial files l8
Diffstat (limited to 'labb8/src/types.h')
| -rwxr-xr-x | labb8/src/types.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/labb8/src/types.h b/labb8/src/types.h new file mode 100755 index 0000000..606f398 --- /dev/null +++ b/labb8/src/types.h @@ -0,0 +1,86 @@ +/* + * TDDD86 Trailblazer + * This file declares fundamental types used by the Trailblazer assignment. + * + * Please do not modify this provided file. Your turned-in files should work + * with an unmodified version of all provided code files. + * + * Author: Marty Stepp, Keith Schwarz, et al + * Slight modifications by Tommy Farnqvist + */ + +#ifndef _types_h +#define _types_h + +/* Type: Loc + * + * A type representing a location in the world, represented as a pair of a row + * and a column. + */ +struct TBLoc { + int row; + int col; +}; + +/* Utility function to construct a Loc from its location. */ +TBLoc makeLoc(int row, int col); + +/* Type: Color + * + * An enumerated type representing a color for a node during an execution of + * Dijkstra's algorithm or A* search. + */ +enum Color { + UNCOLORED, WHITE, GRAY, YELLOW, GREEN, RED +}; + +/* Type: Edge + * + * A type representing an edge in the grid, as encoded by its start and end node. + * This type will be useful when implementing Kruskal's algorithm, though you may + * also find it useful when writing Dijkstra's algorithm or A* search. + */ +struct TBEdge { + TBLoc start; + TBLoc end; +}; + +/* Utility function to create an Edge from its endpoints. */ +TBEdge makeEdge(TBLoc start, TBLoc end); + + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* The functions below this point are provided for convenience and are not + * strictly necessary for your implementation. + */ + +/* Comparison operators for Loc and Edge. Our Map and Set type cannot store + * custom structs as keys (for a map) or values (for a set) unless they can be + * compared with the relational operators. You will probably not directly use + * these in your solution, but you're welcome to do so if you find them useful. + */ +bool operator < (TBLoc lhs, TBLoc rhs); +bool operator > (TBLoc lhs, TBLoc rhs); +bool operator == (TBLoc lhs, TBLoc rhs); +bool operator != (TBLoc lhs, TBLoc rhs); +bool operator <= (TBLoc lhs, TBLoc rhs); +bool operator >= (TBLoc lhs, TBLoc rhs); + +bool operator < (TBEdge lhs, TBEdge rhs); +bool operator > (TBEdge lhs, TBEdge rhs); +bool operator == (TBEdge lhs, TBEdge rhs); +bool operator != (TBEdge lhs, TBEdge rhs); +bool operator <= (TBEdge lhs, TBEdge rhs); +bool operator >= (TBEdge lhs, TBEdge rhs); + +/* Hash function for Loc and Edge. These functions are provided so that you can + * store Locs and Edges in our HashMap or HashSet type, which require a hashCode + * function to be available. You will probably not directly use these in your + * solution, but you're welcome to do so if you find them useful. + */ +int hashCode(TBLoc l); +int hashCode(TBEdge e); + +#endif |
