Public Member Functions | Private Member Functions | Private Attributes

# CargoSorter Class Reference

Predicate to sort CargoDataEntries with stl algorithms. More...

## Public Member Functions
| CargoSorter (CargoSortType t=ST_STATION_ID, SortOrder o=SO_ASCENDING)
CargoSortType | GetSortType ()
bool | operator() (const CargoDataEntry *cd1, const CargoDataEntry *cd2) const
| Sorting operator.
## Private Member Functions
template<class Tid >
bool | SortId (Tid st1, Tid st2) const
| Helper for sorting by ID.
bool | SortCount (const CargoDataEntry *cd1, const CargoDataEntry *cd2) const
| Helper for sorting by cargo count.
bool | SortStation (StationID st1, StationID st2) const
| Helper for sorting by station name.
## Private Attributes
CargoSortType | type
SortOrder | order

## Detailed Description

Predicate to sort CargoDataEntries with stl algorithms.

Can sort by different CargoSortTypes.

Definition at line 817 of file station_gui.cpp.

## Member Function Documentation

bool CargoSorter::operator() | ( | const CargoDataEntry * | cd1,
|  | const CargoDataEntry * | cd2 |
| ) |  |  | const

Sorting operator.

Parameters:

  | cd1 | First entry to be compared.
  | cd2 | Second entry to be compared.

Returns:
  If cd1 < cd2 according to the current sort criteria.

Definition at line 1146 of file station_gui.cpp.

References CargoDataEntry::GetCargo(), CargoDataEntry::GetStation(), SortCount(), SortStation(), ST_CARGO_ID, ST_COUNT, ST_STATION_ID, and ST_STATION_STRING.

bool CargoSorter::SortCount | ( | const CargoDataEntry * | cd1,
|  | const CargoDataEntry * | cd2 |
| ) |  |  | const`[private]`

Helper for sorting by cargo count.

Parameters:

  | cd1 | First CargoDataEntry to compare.
  | cd2 | Second CargoDataEntry to compare.

Returns:
  If cd1 is to be inserted above cd2 given current sort criteria.

Definition at line 1181 of file station_gui.cpp.

References CargoDataEntry::GetCount(), CargoDataEntry::GetStation(), and SortStation().

Referenced by operator()().

template<class Tid >

bool CargoSorter::SortId | ( | Tid | id1,
|  | Tid | id2 |
| ) |  |  | const`[private]`

Helper for sorting by ID.

Template Parameters:

  | Tid | ID class; typically StationID or CargoID.

Parameters:

  | id1 | First ID to compare.
  | id2 | Second ID to compare.

Returns:
  If cd1 < cd2 in ascending, or id2 < id1 in descending mode.

Definition at line 1170 of file station_gui.cpp.

Referenced by SortStation().

bool CargoSorter::SortStation | ( | StationID | st1,
|  | StationID | st2 |
| ) |  |  | const`[private]`

Helper for sorting by station name.

Parameters:

  | st1 | ID of first station to compare.
  | st2 | ID of second station to compare.

Returns:
  If st1 is to be inserted above st2 given current sort criteria.

Definition at line 1200 of file station_gui.cpp.

References SpecializedStation< Station, false >::IsValidID(), lastof, MAX_LENGTH_STATION_NAME_CHARS, SetDParam(), and SortId().

Referenced by operator()(), and SortCount().

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

- src/station_gui.cpp