Knight-Path 1.0.D018
Public Member Functions | Private Member Functions | Private Attributes

taxi_distance Class Reference

#include <taxi_distance.h>

List of all members.

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_distanceoperator= (const taxi_distance &rhs)

Private Member Functions

 taxi_distance ()

Private Attributes

position goal

Detailed Description

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.


Constructor & Destructor Documentation

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

Parameters:
agoalThe "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.

Parameters:
rhsThe 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.


Member Function Documentation

bool taxi_distance::operator() ( const position lhs,
const position rhs 
) [inline]

The function call operator is used by the sort algorithm to compare two positions.

Parameters:
lhsThe left hand side of the "less than" comparison.
rhsThe 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.

Parameters:
rhsThe right hand side of the assignment.

Definition at line 84 of file taxi_distance.h.


Member Data Documentation

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.


The documentation for this class was generated from the following file: