EnumerateGenerator

struct EnumerateGenerator<Base : GeneratorType>

The GeneratorType for EnumerateSequence. EnumerateGenerator wraps a Base GeneratorType and yields successive Int values, starting at zero, along with the elements of the underlying Base:

var g = EnumerateGenerator(["foo", "bar"].generate())
g.next() // (0, "foo")
g.next() // (1, "bar")
g.next() // nil

Note:: idiomatic usage is to call enumerate instead of constructing an EnumerateGenerator directly.

Inheritance GeneratorType, SequenceType, _SequenceType, _Sequence_Type View Protocol Hierarchy →
Associated Types
Element = (index: Int, element: Base.Element)

The type of element returned by next().

Generator = EnumerateGenerator<Base>

A type whose instances can produce the elements of this sequence, in order.

Import import Swift

Initializers

init(_:)

Construct from a Base generator

Declaration

init(_ base: Base)

Instance Methods

func generate()

EnumerateGenerator is also a SequenceType, so it generates a copy of itself

Declaration

func generate() -> EnumerateGenerator<Base>
mutating func next()

Advance to the next element and return it, or nil if no next element exists.

Requires: no preceding call to self.next() has returned nil.

Declaration

mutating func next() -> Element?