Class TravelingCosts<TItem, TDistance>
Implementation of distance calculation from an arbitrary point to the given destination.
Inheritance
IComparer<TItem>
TravelingCosts<TItem, TDistance>
Assembly: Mars.Common.dll
Syntax
public class TravelingCosts<TItem, TDistance> : IComparer<TItem>
Type Parameters
Name |
Description |
TItem |
Type of the points. |
TDistance |
Type of the distance. |
Constructors
TravelingCosts(Func<TItem, TItem, TDistance>, TItem)
Declaration
public TravelingCosts(Func<TItem, TItem, TDistance> distance, TItem destination)
Parameters
Type |
Name |
Description |
Func<TItem, TItem, TDistance> |
distance |
|
TItem |
destination |
|
Properties
Destination
Declaration
public TItem Destination { get; }
Property Value
Methods
Compare(TItem, TItem)
Compares 2 points by the distance from the destination.
Declaration
public int Compare(TItem x, TItem y)
Parameters
Type |
Name |
Description |
TItem |
x |
Left point. |
TItem |
y |
Right point. |
Returns
Type |
Description |
System.Int32 |
-1 if x is closer to the destination than y;
0 if x and y are equally far from the destination;
1 if x is farther from the destination than y.
|
From(TItem)
Declaration
public TDistance From(TItem departure)
Parameters
Type |
Name |
Description |
TItem |
departure |
|
Returns
Type |
Description |
TDistance |
|
Extension Methods