|
OpenTTD GameScript API 20251028-master-g6295310f25
|
Class that creates a list which can keep item/value pairs, which you can walk. More...
#include <script_list.hpp>
Public Types | |
| enum | SorterType { SORT_BY_VALUE , SORT_BY_ITEM } |
| Type of sorter. More... | |
Public Member Functions | |
| void | AddItem (int item, int value) |
| Add a single item to the list. | |
| void | RemoveItem (int item) |
| Remove a single item from the list. | |
| void | Clear () |
| Clear the list, making Count() returning 0 and IsEmpty() returning true. | |
| bool | HasItem (int item) |
| Check if an item is in the list. | |
| int | Begin () |
| Go to the beginning of the list and return the item. | |
| int | Next () |
| Go to the next item in the list and return the item. | |
| bool | IsEmpty () |
| Check if a list is empty. | |
| bool | IsEnd () |
| Check if there is a element left. | |
| int | Count () |
| Returns the amount of items in the list. | |
| int | GetValue (int item) |
| Get the value that belongs to this item. | |
| bool | SetValue (int item, int value) |
| Set a value of an item directly. | |
| void | Sort (SorterType sorter, bool ascending) |
| Sort this list by the given sorter and direction. | |
| void | AddList (GSList *list) |
| Add one list to another one. | |
| void | SwapList (GSList *list) |
| Swap the contents of two lists. | |
| void | RemoveAboveValue (int value) |
| Removes all items with a higher value than 'value'. | |
| void | RemoveBelowValue (int value) |
| Removes all items with a lower value than 'value'. | |
| void | RemoveBetweenValue (int start, int end) |
| Removes all items with a value above start and below end. | |
| void | RemoveValue (int value) |
| Remove all items with this value. | |
| void | RemoveTop (int count) |
| Remove the first count items. | |
| void | RemoveBottom (int count) |
| Remove the last count items. | |
| void | RemoveList (GSList *list) |
| Remove everything that is in the given list from this list (same item index that is). | |
| void | KeepAboveValue (int value) |
| Keep all items with a higher value than 'value'. | |
| void | KeepBelowValue (int value) |
| Keep all items with a lower value than 'value'. | |
| void | KeepBetweenValue (int start, int end) |
| Keep all items with a value above start and below end. | |
| void | KeepValue (int value) |
| Keep all items with this value. | |
| void | KeepTop (int count) |
| Keep the first count items, i.e. | |
| void | KeepBottom (int count) |
| Keep the last count items, i.e. | |
| void | KeepList (GSList *list) |
| Keeps everything that is in the given list from this list (same item index that is). | |
| void | Valuate (function valuator_function,...) |
| Give all items a value defined by the valuator you give. | |
Static Public Attributes | |
| static const bool | SORT_ASCENDING = true |
| Sort ascending. | |
| static const bool | SORT_DESCENDING = false |
| Sort descending. | |
Class that creates a list which can keep item/value pairs, which you can walk.
| enum GSList::SorterType |
| void GSList::AddItem | ( | int | item, |
| int | value | ||
| ) |
Add a single item to the list.
| item | the item to add. Should be unique, otherwise it is ignored. |
| value | the value to assign. |
| void GSList::AddList | ( | GSList * | list | ) |
Add one list to another one.
| list | The list that will be added to the caller. |
| int GSList::Begin | ( | ) |
Go to the beginning of the list and return the item.
To get the value use list.GetValue(list.Begin()).
| int GSList::Count | ( | ) |
Returns the amount of items in the list.
| int GSList::GetValue | ( | int | item | ) |
Get the value that belongs to this item.
| item | the item to get the value from |
| bool GSList::HasItem | ( | int | item | ) |
Check if an item is in the list.
| item | the item to check for. |
| bool GSList::IsEmpty | ( | ) |
Check if a list is empty.
| bool GSList::IsEnd | ( | ) |
| void GSList::KeepAboveValue | ( | int | value | ) |
Keep all items with a higher value than 'value'.
| value | the value above which all items are kept. |
| void GSList::KeepBelowValue | ( | int | value | ) |
Keep all items with a lower value than 'value'.
| value | the value below which all items are kept. |
| void GSList::KeepBetweenValue | ( | int | start, |
| int | end | ||
| ) |
Keep all items with a value above start and below end.
| start | the lower bound of the to be kept values (exclusive). |
| end | the upper bound of the to be kept values (exclusive). |
| void GSList::KeepBottom | ( | int | count | ) |
Keep the last count items, i.e.
remove everything except the last count items.
| count | the amount of items to keep. |
| void GSList::KeepList | ( | GSList * | list | ) |
Keeps everything that is in the given list from this list (same item index that is).
| list | the list of items to keep. |
| void GSList::KeepTop | ( | int | count | ) |
Keep the first count items, i.e.
remove everything except the first count items.
| count | the amount of items to keep. |
| void GSList::KeepValue | ( | int | value | ) |
Keep all items with this value.
| value | the value to keep. |
| int GSList::Next | ( | ) |
Go to the next item in the list and return the item.
To get the value use list.GetValue(list.Next()).
| void GSList::RemoveAboveValue | ( | int | value | ) |
Removes all items with a higher value than 'value'.
| value | the value above which all items are removed. |
| void GSList::RemoveBelowValue | ( | int | value | ) |
Removes all items with a lower value than 'value'.
| value | the value below which all items are removed. |
| void GSList::RemoveBetweenValue | ( | int | start, |
| int | end | ||
| ) |
Removes all items with a value above start and below end.
| start | the lower bound of the to be removed values (exclusive). |
| end | the upper bound of the to be removed values (exclusive). |
| void GSList::RemoveBottom | ( | int | count | ) |
Remove the last count items.
| count | the amount of items to remove. |
| void GSList::RemoveItem | ( | int | item | ) |
Remove a single item from the list.
| item | the item to remove. If not existing, it is ignored. |
| void GSList::RemoveList | ( | GSList * | list | ) |
Remove everything that is in the given list from this list (same item index that is).
| list | the list of items to remove. |
| void GSList::RemoveTop | ( | int | count | ) |
Remove the first count items.
| count | the amount of items to remove. |
| void GSList::RemoveValue | ( | int | value | ) |
Remove all items with this value.
| value | the value to remove. |
| bool GSList::SetValue | ( | int | item, |
| int | value | ||
| ) |
Set a value of an item directly.
| item | the item to set the value for. |
| value | the value to give to the item |
| void GSList::Sort | ( | SorterType | sorter, |
| bool | ascending | ||
| ) |
Sort this list by the given sorter and direction.
| sorter | the type of sorter to use |
| ascending | if true, lowest value is on top, else at bottom. |
| void GSList::SwapList | ( | GSList * | list | ) |
Swap the contents of two lists.
| list | The list that will be swapped with. |
| void GSList::Valuate | ( | function | valuator_function, |
| ... | |||
| ) |
Give all items a value defined by the valuator you give.
| valuator_function | The function which will be doing the valuation. |
| ... | The params to give to the valuators (minus the first param, which is always the index-value we are valuating). |