# helpers.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "engine.h"`
`#include <new>`
`#include "misc/blob.hpp"`

Go to the source code of this file.

## Defines

#define | B (*(CBlobT<EngineID>*)el)

## Functions

void | EngList_Create (EngineList *el)
| Create Engine List (and initialize it to empty).
void | EngList_Destroy (EngineList *el)
| Destroy Engine List (and free its contents).
uint | EngList_Count (const EngineList *el)
| Return number of items stored in the Engine List.
void | EngList_Add (EngineList *el, EngineID eid)
| Add new item at the end of Engine List.
EngineID * | EngList_Items (EngineList *el)
| Return pointer to the items array held by Engine List.
void | EngList_RemoveAll (EngineList *el)
| Clear the Engine List (by invalidating all its items == reseting item count to zero).
void | EngList_Sort (EngineList *el, EngList_SortTypeFunction compare)
| Sort all items using qsort() and given 'CompareItems' function.
void | EngList_SortPartial (EngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
| Sort selected range of items (on indices @ <begin, begin+num_items-1>).

## Detailed Description

Definition in file helpers.cpp.

## Function Documentation

void EngList_Add | ( | EngineList * | el,
|  | EngineID | eid |
| ) |  |  |

Add new item at the end of Engine List.

Append one item at the end of engine list.

Parameters:

  | el | list o which to add an engine
  | eid | engine to add to the list

Definition at line 49 of file helpers.cpp.

Referenced by GenerateReplaceVehList().

uint EngList_Count | ( | const EngineList * | el | ) |

Return number of items stored in the Engine List.

Returns number of items in the engine list.

Parameters:

  | el | list for count inquiry

Returns:
  the desired count

Definition at line 40 of file helpers.cpp.

Referenced by DrawEngineList(), and GenerateLists().

void EngList_Create | ( | EngineList * | el | ) |

Create Engine List (and initialize it to empty).

Creates engine list.

Parameters:

  | el | list to be created

Definition at line 21 of file helpers.cpp.

void EngList_Destroy | ( | EngineList * | el | ) |

Destroy Engine List (and free its contents).

Deallocate and destroy engine list.

Parameters:

  | el | list to be destroyed

Definition at line 30 of file helpers.cpp.

EngineID* EngList_Items | ( | EngineList * | el | ) |

Return pointer to the items array held by Engine List.

Returns engine list items as C array.

Parameters:

  | el | list from which the array pointer has to be returned

Returns:
  the pointer required

Definition at line 58 of file helpers.cpp.

void EngList_RemoveAll | ( | EngineList * | el | ) |

Clear the Engine List (by invalidating all its items == reseting item count to zero).

Removes all items from engine list.

Parameters:

  | el | list to be cleared

Definition at line 66 of file helpers.cpp.

Referenced by GenerateLists(), and GenerateReplaceVehList().

void EngList_Sort | ( | EngineList * | el,
|  | EngList_SortTypeFunction | compare |
| ) |  |  |

Sort all items using qsort() and given 'CompareItems' function.

qsort of the engine list

Parameters:

  | el | list to be sorted
  | compare | function for evaluation of the quicksort

Definition at line 75 of file helpers.cpp.

Referenced by GenerateReplaceVehList().

void EngList_SortPartial | ( | EngineList * | el,
|  | EngList_SortTypeFunction | compare,
|  | uint | begin,
|  | uint | num_items |
| ) |  |  |

Sort selected range of items (on indices @ <begin, begin+num_items-1>).

qsort of specified portion of the engine list

Parameters:

  | el | list to be sorted
  | compare | function for evaluation of the quicksort
  | begin | start of sorting
  | num_items | count of items to be sorted

Definition at line 86 of file helpers.cpp.