Array
The array class represents a dynamically-scaled mutable list of items.
Initializers
public init(initialCapacity: UInt32)
Create an empty array with a given internal capacity.
public init(cArray: Pointer<Type>, length: UInt32)
Create an array from a C-style array/pointer with a given length, if the length of pointer is invalid behavior is undefined. Deallocation is opted out by default with this. Do note that if the array is expanded then the pointer will not be deallocated. Only keep persistent pointers in VSL array of to interface with.
Methods
public func append(value: Type) -> Void
Appends an element to the end of the array
public func prepend(value: Type) -> Void
Prepends an element to the beginning of the array
public func reverse() -> Void
Performs in IN-PLACE REVERSAL of the array. This does not return a new copy for that used the Array#reserved() method.
public func deallocOptOut() -> Void
Prevents the backing buffer from being deallocated by VSL. Use this if you get the value from an external source
Subscripts
public subscript(index: Int32) -> Type
Subscript access for index. Indexes start at zero to Array#length - 1. Negative indexes start indexing from the back of the array. This will panic if an invalid index is attempted to be indexed. To access as an optional you can use Array#get.
public subscript(from: Int32, to: Int32) -> Array<Type>
Subscript access which returns a subarray. This is [A, B). So calling this as
sliceFrom: 1, to: 1
would return an empty array. If the end index is less than or equal to the start index no value will be returned. Negaative values will be handled like in a normal subscript. If the second is past the end of the array it will merely return as many items as possiblepublic subscript(from: Int32, count: Int32) -> Array<Type>
Subscript access which returns a subarray using a length and start index. Negative index values are supported but a negative or zero length will return an empty array.