Knight-Path 1.0.D018
|
#include <taxi_distance.h>
Public Member Functions | |
~taxi_distance () | |
taxi_distance (const position &agoal) | |
bool | operator() (const position &lhs, const position &rhs) |
taxi_distance (const taxi_distance &rhs) | |
taxi_distance & | operator= (const taxi_distance &rhs) |
Private Member Functions | |
taxi_distance () | |
Private Attributes | |
position | goal |
The taxi_distance class is used to represent the comparison to be used when sorting a list of positions by their relative distances to a goal position.
This is used, for example, when sorting a list of potential knight moves:
position::list_t candidates = from.knight_moves(); sort(candidates.begin(), candidates.end(), taxi_distance(to));
Definition at line 35 of file taxi_distance.h.
taxi_distance::~taxi_distance | ( | ) | [inline] |
The destructor. It is not virtual, thou shalt not derive from it.
Definition at line 42 of file taxi_distance.h.
taxi_distance::taxi_distance | ( | const position & | agoal | ) | [inline] |
The constructor
agoal | The "to" position of interest. |
Definition at line 50 of file taxi_distance.h.
taxi_distance::taxi_distance | ( | const taxi_distance & | rhs | ) | [inline] |
The copy constructor. Do not use.
rhs | The right hand side of the initialization. |
Definition at line 73 of file taxi_distance.h.
taxi_distance::taxi_distance | ( | ) | [private] |
The default constructor. Do not use.
The function call operator is used by the sort algorithm to compare two positions.
lhs | The left hand side of the "less than" comparison. |
rhs | The right hand side of the "less than" comparison. |
Definition at line 62 of file taxi_distance.h.
taxi_distance& taxi_distance::operator= | ( | const taxi_distance & | rhs | ) | [inline] |
The assignment operator. Do not use.
rhs | The right hand side of the assignment. |
Definition at line 84 of file taxi_distance.h.
position taxi_distance::goal [private] |
The goal instance variable is used to remember the "to" position, when comparing two positions for their relative distance to the goal.
Definition at line 99 of file taxi_distance.h.