DataObjectListInMemory
¶
DataObjectListInMemory is a data object class instantiated for Lua arrays defined in the DataObject definition schema. This class is intended to be used in simulation scripts by storing data entirely in-memory, unlike general DataObjectList, which can retrieve data from external sources.
names = DataObjectListInMemory:create("list")
names:addItem(DataObjectString:create("1", "Ricky"))
names:addItem(DataObjectString:create("2", "Rob"))
assertEq(names:itemCount(), 2)
-- Indexes start with zero.
names:removeItem(0)
-- `getItem` is specific to in-memory list data object.
-- For generic lists `acquireItem` should be used instead.
assertEq(names:getItem(0):getValue(), "Rob")
Inherits properties and message types from DataObjectListInMemoryMetadata.
| create() | Creates an instance of DataObjectListInMemory |
| addItem() | Adds an item to the end of a list |
| insertItem() | Adds an item to a list at the given index |
| removeItem() | Removes an item from a list at the given index |
| removeAllItems() | Removes all list items |
| getItem() | Gets an item at the given index |
| iterateItems() | Returns an iterator that you can use to iterate over items of a data object list |
Creates an instance of DataObjectListInMemory.
| objectName | (string) | The name of the object. |
| items | (DataObject[]) | List of items to insert. |
Adds an item to the end of a list.
| item | (DataObject) | An item to add. |
Adds an item to a list at the given index.
| index | (number) | Index of the item. |
| item | (DataObject) | An item to insert. |
Removes an item from a list at the given index.
| index | (number) | Index of the item. |
Removes all list items.
Gets an item at the given index.
Unlike acquireItem, this function is specific to in-memory lists, and its semantics do not require managing resources.
When writing generic code over lists acquireItem and releaseItem should be used instead.
| index | (number) | Index of the item. |
| (DataObject) |
Returns an iterator that you can use to iterate over items of a data object list.