constructor
appends an element to the list
appends an array to the list
empties the list
Returns index of the first matching element. -1 if not found
Inserts an array into this list
Inserts an element into this list
Loads array into this list
Reads an element at an index
Reads the last element in list.
returns last elements in list. number of elements to return is specified in count
Read a slice from the list.
Removes last elements(s) starting from an index; number of elements to remove is in count
Removes last elements(s); number of elements to remove is in count
Writes the list to a file.
Changes the value of element at an index.
shrinks the size of the list, removing last elements.
Exports this list into a array
length of the list
Unittest for List
List!ubyte list = new List!ubyte; //`List.insert` and `List.add` and `List.toArray` list.add(0); list.add(1); list.insert(1, 2); assert(list.toArray() == [0, 2, 1]); //`List.indexOf` assert(list.indexOf(1) == 2); //`List.clear` list.clear; assert(list.length == 0); //`List.loadArray` list.loadArray([0, 1, 2, 3]); assert(list.length == 4); assert(list.indexOf(3) == 3); //`List.addArray` list.addArray([4, 5, 6, 7, 8]); assert(list.length == 9); //`List.set` and `List.read` list.set(0, 1); assert(list.read(0) == 1); //`List.readLast` assert(list.readLast() == 8); assert(list.readLast(2) == [7, 8]); //`List.readRange` assert(list.readRange(0, 2) == [1, 1]); //`List.remove` list.remove(0, 2); assert(list.read(0) == 2); //`List.removeLast` list.removeLast(2); assert(list.readLast() == 6); destroy(list);
Use to manage dynamic arrays that frequently change lengths
Provides more functionality for arrays, like searching in arrays, removing elements...