Generic list of items that is stored in a given block.
Note: If you make any changes to the item contents manually, do not forget to notify the list about the changes by calling updated()
method.
Note: Each list item should at least hold a numerical ID ("id" field). The ID of a list item should be unique in that list. If the items have an amount accociated, the field "amount" should also be given. You can get the next unique free ID from nextID property.
Note: If you remove the items from the list bypassing the removeItem()
call, do not forget to call updated()
method to notify the list about the changes.
This class is described in detail in Generic Containers article.
Adds an item to the list.
Parameters:
item
New item.
Returns:
Operation status.
ok
- operation successful.
idExists
- item with this ID exists in the list.
decrease (item:Item, ?amount:Int):Bool
Decreases list item amount field by given amount. Removes the item if amount equals zero.
Parameters:
item
List item.
amount
Amount to decrease by.
Returns:
True if operation was successful, false if the item was not in the list.
getByField (field:String, val:Dynamic):Item
Returns the first list item with a given field value.
Parameters:
field
List item field.
val
List item value.
Returns:
List item. Returns null if not found.
Returns list item index by its ID.
Parameters:
id
List item ID.
Returns:
List item index. Returns -1 if not found.
Returns list item by its ID.
Parameters:
id
List item ID.
Returns:
List item. Returns null if not found.
Returns whether the list has an item with this ID.
Parameters:
id
List item ID.
Returns:
True if the list has an item with this ID. False otherwise.