![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
A generic array template class for moveable objects eg. structs or fundamental data types like UInt32, Real, etc.
The array class works for moveable objects only, use ObjectArray class for storing non-moveable objects.
This class is based on the NTL Vector container, see http://www.ultimatepp.org
Construct an empty array.
Murl.Array.String new()
Construct an array containing a single item.
Murl.Array.String new(String item)
item | The item. |
Construct an array containing two items.
Murl.Array.String new(String item1, String item2)
item1 | The first item. |
item2 | The second item. |
Construct an array containing three items.
Murl.Array.String new(String item1, String item2, String item3)
item1 | The first item. |
item2 | The second item. |
item3 | The third item. |
Construct an array from an already existing one, performing a deep copy.
Murl.Array.String new(Murl.Array.String other)
other | The array to copy. |
Clear the array and remove the underlying storage.
Clear()
Empty the array, but keep the underlying storage.
Empty()
Shrink the array so that the underlying storage is only as large as necessary.
Shrink()
Reduce the array to a given number of items.
n | The new number of items in the array, must be smaller than the current item count. |
Reduce the array by removing a given number of items from the end.
n | The number of items to remove from the end. |
Reserve storage space. If the given size is less than the actual size, nothing is done.
Reserve(Integer n)
n | The number of items the underlying storage should hold. |
Set the actual number of items in the array. If the given number is smaller than the current size, the array is trimmed, and existing items beyond the new size are destroyed. If the given number is higher, new items are initialized via the value type's default constructor. If the given number is also higher than the underlying storage's capacity, the storage is enlarged to hold exactly the requested number of items.
n | The new number of items in the array. |
Set the actual number of items in the array. If the given number is smaller than the current size, the array is trimmed, and existing items beyond the new size are destroyed. If the given number is higher, new items are initialized via the given value's copy constructor. If the given number is also higher than the underlying storage's capacity, the storage is enlarged to hold exactly the requested number of items.
Boolean SetCount(Integer n, String item)
n | The new number of items in the array. |
item | The value to initialize any newly added items with. |
Set the actual number of items in the array and reserve extra storage space. If the given number is smaller than the current size, the array is trimmed, and existing items beyond the new size are destroyed. If the given number is higher, new items are initialized via the value type's default constructor. If the given number is also higher than the underlying storage's capacity, the storage is enlarged and some extra capacity is added.
Boolean SetCountAndReserve(Integer n)
n | The new number of items in the array. |
Set the actual number of items in the array and reserve extra storage space. If the given number is smaller than the current size, the array is trimmed, and existing items beyond the new size are destroyed. If the given number is higher, new items are initialized via the given value's copy constructor. If the given number is also higher than the underlying storage's capacity, the storage is enlarged and some extra capacity is added.
Boolean SetCountAndReserve(Integer n, String item)
n | The new number of items in the array. |
item | The value to initialize any newly added items with. |
Initialize an item with a given item. If the given index is greater than the actual array size, the array is enlarged as needed.
String Set(Integer index, String item)
index | The index of the item to set. |
item | The source item to copy. |
Initialize a range of items with a given item. If the given index plus the count is greater than the actual array size, the array is enlarged as needed.
Boolean Set(Integer index, String item, Integer count)
index | The index of the first item to set. |
item | The source item to copy. |
count | The number of items to set. |
Fill all items with a given item.
Fill(String item)
item | The source item to copy. |
Swap two array items.
Swap(Integer index1, Integer index2)
index1 | The index of the first item. |
index2 | The index of the second item. |
Exchange the content of the array with a given second one.
Murl.Array.String Swap(Murl.Array.String other)
other | The second array. |
Add a new item at the end of the array. The new item entry is initialized using the value type's default constructor.
String Add()
Add a given item at the end of the array. The new item entry is initialized using the given item's copy constructor.
item | The given item to be inserted at the end of the array. |
Add a given array of items at the end of the array. The new item entries are initialized using the original items' copy constructors.
Boolean Add(Murl.Array.String other)
other | The given item array to be inserted. |
Add a subset of given array of items at the end of the array. The new item entries are initialized using the original items' copy constructors.
Boolean Add(Murl.Array.String other, Integer offset, Integer count)
other | The given source item array. |
offset | The index into the source array specifying the first item to copy. |
count | The number of source array items to copy. |
Add a given number of new items at the end of the array. The new item entries are initialized using the value type's default constructor.
AddN(Integer count)
count | The number of new items to be inserted at the end of the array. |
Insert a new item at a given position. The new item entry is initialized using the value type's default constructor.
index | the zero-based index where the new item should be inserted. |
Insert a given item at a given position. The new item is initialized using the given item's copy constructor.
String Insert(Integer index, String item)
index | the zero-based index where the new item should be inserted. |
item | The given item to be inserted. |
Insert a number of copies of a given item at a given position. The new item entries are initialized using the given item's copy constructor.
Boolean Insert(Integer index, String item, Integer count)
index | the zero-based index where the new items should be inserted. |
item | The given item to be inserted. |
count | The number of copies of the given item to insert. |
Insert a given array of items at a given position. The new item entries are initialized using the original items' copy constructors.
Boolean Insert(Integer index, Murl.Array.String other)
index | the zero-based index where the new items should be inserted. |
other | The given item array to be inserted. |
Insert a subset of given array of items at a given position. The new item entries are initialized using the original items' copy constructors.
Boolean Insert(Integer index, Murl.Array.String other, Integer offset, Integer count)
index | the zero-based index where the new items should be inserted. |
other | The given source item array. |
offset | The index into the source array specifying the first item to copy. |
count | The number of source array items to copy. |
Insert a given number of new items at a given position. The new item entries are initialized using the value type's default constructor.
Boolean InsertN(Integer index, Integer count)
index | the zero-based index where the new items should be inserted. |
count | The number of new items to be inserted. |
Remove (and destroy) an item at a given position and get a copy of the item.
String RemoveGet(Integer index)
index | The zero-based index from where to remove the item. |
Remove (and destroy) a number of items at a given position.
Boolean Remove(Integer index, Integer count)
index | The zero-based index from where to remove the items. |
count | The number of items to remove. |
Remove (and destroy) a number of items at given positions.
Remove(Murl.Array.SInt32 sortedIndices)
sortedIndices | A sorted array of indices where to remove the items. |
Find the first occurrence of a given item in the array.
item | The item to find. |
Find the first occurrence of a given item in the array.
Integer Find(String item, Integer firstIndex)
item | The item to find. |
firstIndex | The index where to start searching. |
Find the last occurrence of a given item in the array.
item | The item to find. |
Find the last occurrence of a given item in the array.
Integer FindLast(String item, Integer lastIndex)
item | The item to find. |
lastIndex | The index where to start searching. |
Retrieve the first item from the array. Synonymous to Bottom().
String Front()
Retrieve the last item from the array. Synonymous to Top().
String Back()
Retrieve the first item from the array.
String Bottom()
Retrieve the last item from the array.
String Top()
Remove the last item from the array.
String Pop()
Retrieve the item at a given position from the array. If the given index is greater than the actual array size, the array is enlarged as needed, using the value type's default constructor for initializing.
index | The zero-based index of the item to retrieve. |
Retrieve the item at a given position from the array. If the given index is greater than the actual array size, the array is enlarged as needed, using the given reference item's copy constructor for initializing.
String At(Integer index, String item)
index | The zero-based index of the item to retrieve. |
item | The reference item used for initialization. |
Get the number of items in the array.
Integer GetCount()
Get the number of items in the array.
Integer GetCountUInt32()
Check if the array is empty.
Boolean IsEmpty()
Get the number of actually allocated items.
Integer GetAlloc()
Compare the array to another one.
Boolean IsEqual(Murl.Array.String other)
other | The array to compare. |
Check if a given index is a valid index.
Boolean IsIndexValid(Integer index)
index | The index to check. |
Get the item at a given position from the array.
index | The zero-based index of the item to retrieve. |
Get the number of bytes of the underlying raw array.
Integer GetByteSize()
ReAllocMove(Integer numAlloc)
The length operator is denoted by the unary prefix operator #.
The "equal to" comparison operator, calls IsEqual().
Retrieve the item at a given position from the array.
index | The zero-based index of the item to retrieve. |