namespace sys.core.lang
class Vector
this{copy: Vector};
this{move copy: Vector};
Copy/move constructor. Creates a new instance containing a copy of the input parameter, or moves the data if the input parameter is an expiring value.
copy=> the vector to copy/move from
def @attr(copy: Vector);
def @attr(move copy: Vector);
Assignment/move operator. Assign the current instance with a copy or a move of the input data.
copy=> the vector to copy/move from
def Add(item: T);
def Add(move item: T);
def Add(items: Vector);
def Add(items: CArray);
Append a single item or a collection to the end of the vector.
item=> the item to append
items=> the item collection to append
def Fill(value: T);
def Fill(items: Vector);
def Fill(items: CArray);
Copies over all the elements in the static array. If a single value is provided, all elements will be initialized with it. If an array is provided, elements will be copied over in sequence. If the source array is exhausted, the reading index will be reset to 0 and the copying resumed.
value=> the value to fill with
items=> the array to use
func FindIndex(item: T): PtrSize;
func FindIndex(item: T, start: PtrSize): PtrSize;
Searches for an item in the array and returns the first index at which it was found or -1 if the item was not found. The search starts on an index given by the `start` parameter if present or from index 0 otherwise.
item=> the item to search for
start=> the start index for the search
the index where the item was found
func BinaryIndex(item: T): PtrSize;
def BinaryIndex(item: T, start: PtrSize): PtrSize;
Searches for an item in the array and returns the first index at which it was found or -1 if the item was not found. It uses a binary search algorithm and the contents of the container must be sorted in ascending order. If the elements are not sorted, the result is unpredictable. The search starts on an index given by the `start` parameter if present or from index 0 otherwise.
item=> the item to search for
start=> the start index for the search
the index where the item was found
def Insert(pos: PtrSize, item: T);
def Insert(pos: PtrSize, items: CArray);
def Insert(pos: PtrSize, items: Vector);
Inserts an item or a collection of items into the array at a given position. THe array will grow to accommodate the inserted items.
pos=> the position to insert to
item=> the item to insert
items=> the items to insert
def Delete(item: T): PtrSize;
def Delete(items: CArray): PtrSize;
def Delete(items: Vector): PtrSize;
Searches for the first occurrence of an item within the array and if found it removes it.
item=> the item to delete
items=> the items to delete
the number of deleted items
def DeleteAll(item: T): PtrSize;
def DeleteAll(item: CArray): PtrSize;
def DeleteAll(item: Vector): PtrSize;
Searches for all the occurrences of an item within the array and if found removes them all.
item=> the item to remove
the number of deleted items
def DeleteIndex(item: PtrSize): PtrSize;
def DeleteIndex(items: CArray): PtrSize;
def DeleteIndex(items: Vector): PtrSize;
Deletes an item at a given index from the array.
item=> the index to delete
items=> an array of indices to delete
the number of deleted items
def Reverse();
def Reverse(start: PtrSize, end: PtrSize);
Reverses the contents of the array, from beginning to end or between two input indices.
start=> the start index
end=> the end index
func Sum(): T;
Returns the sum of all the items in the array.
the sum
def Sort();
def Sort(low: Int, high: Int);
Sorts the content of the array in ascending order, from beginning to end or between two input indices.
low=> the start index
high=> the end index
def SortDesc();
def SortDesc(low: Int, high: Int);
Sorts the content of the array in descending order, from beginning to end or between two input indices.
low=> the start index
high=> the end index
func @write(ref stream: Stream);
Writes each element of the array to a stream as an Utf8 text. The item count is included.
stream=> the output stream
property Length: PtrSize
Read and writes the length of the vector.
property Capacity: PtrSize
Read and writes the capacity of the vector. Capacity can't be set lower than the Length.
property @index: ref T; get;
Reads and writes a given index from the vector. Accessing an invalid index is an error.
property At: ref T; get;
Reads and writes a given index from the vector. Accessing an index greater than Length will cause all the missing values to be default constructed.
property SysDataPointer: Ptr; get;
Returns a pointer to the data.