Product Type

Array

An ordered, random-access collection.

Members

Bindings

Functions

fun deinit() { sink }

Deinitializes self.

fun count() -> Int

Returns the number of elements in self.

fun is_empty() -> Bool

Returns true if self is empty.

fun capacity() -> Int

The number of elements that can be stored in the array before new storage must be allocated.

fun reserve_capacity(_ n: Int) { inout }

Reserves enough space to store n elements in self.

fun with_mutable_contiguous_storage<E, T: Movable>(_ action: inout [E] (PointerToMutable<Element>) inout -> T) -> T { inout }

Calls action with a pointer to the start of the array's mutable contiguous storage.

fun append(_ source: sink Element) { inout }

Adds a new element at the end of the array.

fun insert(_ source: sink Element, at index: Int) { inout }

Inserts source at index.

fun remove(at index: Int) -> Element { inout }

Removes and returns the element at index.

fun remove_all(keeping_capacity keep_capacity: Bool) { inout }

Removes al elements in the array, keeping existing storage if keep_capacity is true.

fun pop_last() -> Optional<Element> { inout }

Removes and returns the last element of the array.

fun reverse() { inout }

Reverses the elements of self in place.

Subscripts

property contiguous_storage: Pointer<Element> { let }

Projects a pointer to the start of the array's contiguous storage.

subscript pointer_to_element(at position: Int): PointerToMutable<Element> { let }

Projects the address of the element at position.

Initializers

init()

Creates an empty array.

init<E>(count: Int, initialized_with initialize: inout [E] (Int) inout -> Element)

Creates an array whose contents are the results, of calling initialize with the values 0 ..< count, in order.