_ArrayType

protocol _ArrayType
Inheritance ArrayLiteralConvertible, CollectionType, ExtensibleCollectionType, MutableCollectionType, MutableSliceable, RangeReplaceableCollectionType, SequenceType, Sliceable, _CollectionType, _ExtensibleCollectionType, _SequenceType, _Sequence_Type, _Sliceable, __ArrayType View Protocol Hierarchy →
Associated Types
_Buffer : _ArrayBufferType
Element
Generator : GeneratorType

A type that provides the sequence's iteration interface and encapsulates its iteration state.

SubSlice : _Sliceable

The collection type that represents a sub-range of elements.

Though it can't currently be enforced by the type system, the SubSlice type in a concrete implementation of Sliceable should also be Sliceable.

Index : ForwardIndexType

A type that represents a valid position in the collection.

Valid indices consist of the position of every element and a "past the end" position that's not valid for use as a subscript.

_Element

A type that represents a valid position in the collection.

Valid indices consist of the position of every element and a "past the end" position that's not valid for use as a subscript.

Import import Swift

Initializers

init() Required

Construct an empty Array

Declaration

init()

Declared In

_ArrayType , _ExtensibleCollectionType
init(_:) Required

Declaration

init(_ buffer: _Buffer)
init(count:repeatedValue:) Required

Construct an array of count elements, each initialized to repeatedValue

Declaration

init(count: Int, repeatedValue: Self.Generator.Element)
init(arrayLiteral:) Required

Create an instance initialized with elements.

Declaration

init(arrayLiteral elements: Element...)

Declared In

ArrayLiteralConvertible

Instance Variables

var _baseAddressIfContiguous: UnsafeMutablePointer<Self.Element> Required

If the elements are stored contiguously, a pointer to the first element. Otherwise, nil.

Declaration

var _baseAddressIfContiguous: UnsafeMutablePointer<Self.Element> { get }
var _owner: AnyObject? Required

An object that guarantees the lifetime of this array's elements

Declaration

var _owner: AnyObject? { get }
var capacity: Int Required

How many elements the Array can store without reallocation

Declaration

var capacity: Int { get }
var count: Int Required

How many elements the Array stores

Declaration

var count: Int { get }

Declared In

_ArrayType , __ArrayType
var isEmpty: Bool Required

true if and only if the Array is empty

Declaration

var isEmpty: Bool { get }
var endIndex: Index Required

The collection's "past the end" position.

endIndex is not a valid argument to subscript, and is always reachable from startIndex by zero or more applications of successor().

Declaration

var endIndex: Index { get }

Declared In

_CollectionType
var startIndex: Index Required

The position of the first element in a non-empty collection.

Identical to endIndex in an empty collection.

Declaration

var startIndex: Index { get }

Declared In

_CollectionType
var _buffer: _Buffer Required

Declaration

var _buffer: _Buffer { get }

Declared In

__ArrayType

Subscripts

subscript(_: Int) Required

Declaration

subscript(index: Int) -> Self.Generator.Element { get set }
subscript(_: Self.Index) Required

Declaration

subscript(position: Self.Index) -> Self.Generator.Element { get }

Declared In

CollectionType, MutableCollectionType
subscript(_: Range<Self.Index>) Required

Declaration

subscript(_: Range<Self.Index>) -> Self.SubSlice { get set }

Declared In

MutableSliceable, Sliceable
subscript(_: Index) Required

Declaration

subscript(_i: Index) -> _Element { get }

Declared In

_CollectionType

Instance Methods

func +=(inout:rhs:) Required

Operator form of extend

Declaration

func +=<S : SequenceType where Self.Generator.Element == Self.Generator.Element>(inout lhs: Self, rhs: S)
func _doCopyToNativeArrayBuffer() Required

Declaration

func _doCopyToNativeArrayBuffer() -> _ContiguousArrayBuffer<Self._Element>

Declared In

__ArrayType
mutating func append(_:) Required

Append newElement to the Array in O(1) (amortized)

Declaration

mutating func append(newElement: Self.Generator.Element)

Declared In

_ArrayType, _ExtensibleCollectionType
mutating func extend(_:) Required

Append elements from sequence to the Array

Declaration

mutating func extend<S : SequenceType where Self.Generator.Element == Self.Generator.Element>(sequence: S)

Declared In

_ArrayType, _ExtensibleCollectionType
func generate() Required

Return a generator over the elements of this sequence.

Complexity: O(1)

Declaration

func generate() -> Generator

Declared In

SequenceType, _Sequence_Type
mutating func insert(_:atIndex:) Required

Insert newElement at index i.

Invalidates all indices with respect to self.

Complexity: O(count(self)).

Requires: atIndex <= count

Declaration

mutating func insert(newElement: Self.Generator.Element, atIndex i: Int)

Declared In

_ArrayType, RangeReplaceableCollectionType
func join(_:) Required

Declaration

func join<S : SequenceType where Self == Self>(elements: S) -> Self
func reduce(_:combine:) Required

Declaration

func reduce<U>(initial: U, combine: @noescape (U, Self.Generator.Element) -> U) -> U
mutating func removeAll(_:) Required

Erase all the elements. If keepCapacity is true, capacity will not change

Declaration

mutating func removeAll(#keepCapacity: Bool)

Declared In

_ArrayType, RangeReplaceableCollectionType
mutating func removeAtIndex(_:) Required

Remove and return the element at the given index. Returns: the removed element. Worst case complexity: O(N). Requires: count > index

Declaration

mutating func removeAtIndex(index: Int) -> Self.Generator.Element

Declared In

_ArrayType, RangeReplaceableCollectionType
mutating func removeLast() Required

Remove an element from the end of the Array in O(1). Returns: the removed element. Requires: count > 0

Declaration

mutating func removeLast() -> Self.Generator.Element
mutating func removeRange(_:) Required

Remove the indicated subRange of elements

Invalidates all indices with respect to self.

Complexity: O(count(self)).

Can be implemented as:

Swift.removeRange(&self, subRange)

Declaration

mutating func removeRange(subRange: Range<Self.Index>)

Declared In

RangeReplaceableCollectionType
mutating func replaceRange(_:with:) Required

Replace the given subRange of elements with newElements.

Invalidates all indices with respect to self.

Complexity: O(count(subRange)) if subRange.endIndex == self.endIndex and isEmpty(newElements), O(count(self) + count(newElements)) otherwise.

Declaration

mutating func replaceRange<C : CollectionType where Self.Generator.Element == Self.Generator.Element>(subRange: Range<Self.Index>, with newElements: C)

Declared In

RangeReplaceableCollectionType
mutating func reserveCapacity(_:) Required

Reserve enough space to store minimumCapacity elements.

PostCondition: capacity >= minimumCapacity and the array has mutable contiguous storage.

Complexity: O(count)

Declaration

mutating func reserveCapacity(minimumCapacity: Int)

Declared In

_ArrayType, _ExtensibleCollectionType
mutating func sort(_:) Required

Sort self in-place according to isOrderedBefore. Requires: isOrderedBefore induces a strict weak ordering over the elements.

Declaration

mutating func sort(isOrderedBefore: (Self.Generator.Element, Self.Generator.Element) -> Bool)
mutating func splice(_:atIndex:) Required

Insert newElements at index i

Invalidates all indices with respect to self.

Complexity: O(count(self) + count(newElements)).

Can be implemented as:

Swift.splice(&self, newElements, atIndex: i)

Declaration

mutating func splice<S : CollectionType where Self.Generator.Element == Self.Generator.Element>(newElements: S, atIndex i: Self.Index)

Declared In

RangeReplaceableCollectionType