protocol Indexable

A type that provides subscript access to its elements.

Important: In most cases, it's best to ignore this protocol and use CollectionType instead, as it has a more complete interface.

Inheritance View Protocol Hierarchy →
Associated Types
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.

Import import Swift

Instance Variables

var endIndex: Self.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().

Complexity: O(1)


var endIndex: Self.Index { get }
var startIndex: Self.Index Required

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

In an empty collection, startIndex == endIndex.

Complexity: O(1)


var startIndex: Self.Index { get }


subscript(_: Self.Index) Required

Returns the element at the given position.

Complexity: O(1)


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