Class that creates a list which can keep item/value pairs, which you can walk. More...
Public Types | |
enum | SorterType { SORT_BY_VALUE, SORT_BY_ITEM } |
Type of sorter. More... | |
typedef std::set< int32 > | AIItemList |
The list of items inside the bucket. | |
typedef std::map< int32, AIItemList > | AIAbstractListBucket |
The bucket list per value. | |
typedef std::map< int32, int32 > | AIAbstractListMap |
List per item. | |
Public Member Functions | |
void | Clear () |
Clear the list, making Count() returning 0 and IsEmpty() returning true. | |
bool | HasItem (int32 item) |
Check if an item is in the list. | |
int32 | Begin () |
Go to the beginning of the list. | |
int32 | Next () |
Go to the next item in the list. | |
bool | IsEmpty () |
Check if a list is empty. | |
bool | HasNext () |
Check if there is a next element. | |
int32 | Count () |
Returns the amount of items in the list. | |
int32 | GetValue (int32 item) |
Get the value that belongs to this item. | |
bool | SetValue (int32 item, int32 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 (AIAbstractList *list) |
Add one list to another one. | |
void | RemoveAboveValue (int32 value) |
Removes all items with a higher value than 'value'. | |
void | RemoveBelowValue (int32 value) |
Removes all items with a lower value than 'value'. | |
void | RemoveBetweenValue (int32 start, int32 end) |
Removes all items with a value above start and below end. | |
void | RemoveValue (int32 value) |
Remove all items with this value. | |
void | RemoveTop (int32 count) |
Remove the first count items. | |
void | RemoveBottom (int32 count) |
Remove the last count items. | |
void | RemoveList (AIAbstractList *list) |
Remove everything that is in the given list from this list (same item index that is). | |
void | KeepAboveValue (int32 value) |
Keep all items with a higher value than 'value'. | |
void | KeepBelowValue (int32 value) |
Keep all items with a lower value than 'value'. | |
void | KeepBetweenValue (int32 start, int32 end) |
Keep all items with a value above start and below end. | |
void | KeepValue (int32 value) |
Keep all items with this value. | |
void | KeepTop (int32 count) |
Keep the first count items, i.e. | |
void | KeepBottom (int32 count) |
Keep the last count items, i.e. | |
void | KeepList (AIAbstractList *list) |
Keeps everything that is in the given list from this list (same item index that is). | |
void | Valuate (void *valuator_function, int params,...) |
Give all items a value defined by the valuator you give. | |
Data Fields | |
AIAbstractListMap | items |
The items in the list. | |
AIAbstractListBucket | buckets |
The items in the list, sorted by value. | |
Static Public Attributes | |
static const bool | SORT_ASCENDING = true |
Sort ascending. | |
static const bool | SORT_DESCENDING = false |
Sort descnding. | |
Protected Member Functions | |
void | AddItem (int32 item) |
Add a single item to the list. | |
void | RemoveItem (int32 item) |
Remove a single item from the list. |
Class that creates a list which can keep item/value pairs, which you can walk.
void AIAbstractList::AddItem | ( | int32 | item | ) | [protected] |
Add a single item to the list.
item | the item to add. Should be unique, otherwise it is ignored. |
void AIAbstractList::AddList | ( | AIAbstractList * | list | ) |
Add one list to another one.
list | The list that will be added to the caller. |
int32 AIAbstractList::Begin | ( | ) |
Go to the beginning of the list.
int32 AIAbstractList::Count | ( | ) |
Returns the amount of items in the list.
int32 AIAbstractList::GetValue | ( | int32 | item | ) |
Get the value that belongs to this item.
item | the item to get the value from |
bool AIAbstractList::HasItem | ( | int32 | item | ) |
Check if an item is in the list.
item | the item to check for. |
bool AIAbstractList::HasNext | ( | ) |
Check if there is a next element.
In other words, if this is true, Next() will return a valid item.
bool AIAbstractList::IsEmpty | ( | ) |
Check if a list is empty.
void AIAbstractList::KeepAboveValue | ( | int32 | value | ) |
Keep all items with a higher value than 'value'.
value | the value above which all items are kept. |
void AIAbstractList::KeepBelowValue | ( | int32 | value | ) |
Keep all items with a lower value than 'value'.
value | the value below which all items are kept. |
void AIAbstractList::KeepBetweenValue | ( | int32 | start, | |
int32 | 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 AIAbstractList::KeepBottom | ( | int32 | count | ) |
Keep the last count items, i.e.
remove everything except the last count items.
count | the amount of items to keep. |
void AIAbstractList::KeepList | ( | AIAbstractList * | 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 AIAbstractList::KeepTop | ( | int32 | count | ) |
Keep the first count items, i.e.
remove everything except the first count items.
count | the amount of items to keep. |
void AIAbstractList::KeepValue | ( | int32 | value | ) |
Keep all items with this value.
value | the value to keep. |
int32 AIAbstractList::Next | ( | ) |
Go to the next item in the list.
void AIAbstractList::RemoveAboveValue | ( | int32 | value | ) |
Removes all items with a higher value than 'value'.
value | the value above which all items are removed. |
void AIAbstractList::RemoveBelowValue | ( | int32 | value | ) |
Removes all items with a lower value than 'value'.
value | the value below which all items are removed. |
void AIAbstractList::RemoveBetweenValue | ( | int32 | start, | |
int32 | 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 valuens (exclusive). |
void AIAbstractList::RemoveBottom | ( | int32 | count | ) |
Remove the last count items.
count | the amount of items to remove. |
void AIAbstractList::RemoveItem | ( | int32 | item | ) | [protected] |
Remove a single item from the list.
item | the item to remove. If not existing, it is ignored. |
Reimplemented in AIList.
void AIAbstractList::RemoveList | ( | AIAbstractList * | 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 AIAbstractList::RemoveTop | ( | int32 | count | ) |
Remove the first count items.
count | the amount of items to remove. |
void AIAbstractList::RemoveValue | ( | int32 | value | ) |
Remove all items with this value.
value | the value to remove. |
bool AIAbstractList::SetValue | ( | int32 | item, | |
int32 | 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 AIAbstractList::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 AIAbstractList::Valuate | ( | void * | valuator_function, | |
int | params, | |||
... | ||||
) |
Give all items a value defined by the valuator you give.
valuator_function | The function which will be doing the valuation. | |
params | The params to give to the valuators (minus the first param, which is always the index-value we are valuating). |