TObjectList
Array-backed Object List
Methods
Method Clear()
Clears the list.
Removes all objects from list.
Method IsEmpty:Int()
Checks if the list is empty.
Returns
True if the list is empty, else False
Method AddFirst(value:Object)
Adds an object to the start of the list
Method AddLast(value:Object)
Adds an object to the end of the list
Method Contains:Int(obj:Object)
Checks if the list contains a value
Returns
True if the list contains obj, else False
Method First:Object()
Returns the first object in the list
Returns Null if the list is empty.
Method Last:Object()
Returns the last object in the list
Returns Null if the list is empty.
Method RemoveFirst:Object()
Removes and returns the first object in the list.
Returns Null if the list is empty.
Method RemoveLast:Object()
Removes and returns the last object in the list.
Returns Null if the list is empty.
Method ValueAtIndex:Object(index:Int)
Returns the object at the given index.
Throws an exception if the index is out of range (must be 0..list.Count()-1 inclusive).
Method Count:Int()
Counts the list length
Returns
The numbers of objects in the list.
Method Remove:Int(value:Object, removeAll:Int = False, compactOnRemove:Int = True)
Removes an object from the list.
Remove scans the list for the specified value and removes it. By default, only the first found object is removed. Enabling removeAll will result in all instances of value being removed from the list. By default, the list is compacted on each remove. This can be inefficient if removing several objects from a list. Disabling compactOnRemove will skip compaction until either Compact() is called, or the current enumerator completes, or a different list method is called. This mechanism allows for removal of elements during an enumeration.
Method Compact()
Compacts the list.
Use with Remove() and compactOnRemove = False.
Method Copy:TObjectList()
Creates an identical copy of the list.
Method Reverse()
Reverses the order of the list.
Method Reversed:TObjectList()
Creates a new list that is the reversed version of this list.
Method ToArray:Object[]()
Converts the list to an array
Returns
An array of objects
Method Sort(ascending:Int=True, compareFunc:Int( o1:Object,o2:Object ) )
Sort the list in either ascending (default) or decending order.
User types should implement a Compare method in order to be sorted.
Functions
Function FromArray:TObjectList(arr:Object[])
Creates a list from an array
Returns
A new object list