protocol
CollectionType
Inheritance |
SequenceType, _CollectionType, _SequenceType, _Sequence_Type
View Protocol Hierarchy →
|
---|---|
Associated Types |
A type that provides the sequence's iteration interface and encapsulates its iteration state.
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.
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. 3 inherited items hidden. (Show all) |
Import |
|
Instance Variables
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
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
2 inherited items hidden. (Show all)
Subscripts
Declaration
subscript
(
position
:
Self
.
Index
) -
>
Self
.
Generator
.
Element
{
get
}
1 inherited item hidden. (Show all)
Instance Methods
Return a generator over the elements of this sequence.
Complexity: O(1)
Declaration
func
generate
() -
>
Generator
Declared In
SequenceType
, _Sequence_Type
1 inherited item hidden. (Show all)
A multi-pass sequence with addressable positions.
Positions are represented by an associated
Index
type. Whereas an arbitrary sequence may be consumed as it is traversed, a collection is multi-pass: any element may be revisited merely by saving its index.The sequence view of the elements is identical to the collection view. In other words, the following code binds the same series of values to
x
as doesfor x in self {}
: