GeneratorSequence

struct GeneratorSequence<G : GeneratorType>

A sequence built around a generator of type G.

Useful mostly to recover the ability to use for...in, given just a generator g:

for x in GeneratorSequence(g) { ... }
Inheritance GeneratorType, SequenceType, _SequenceType, _Sequence_Type View Protocol Hierarchy →
Associated Types
Generator = GeneratorSequence<G>

Type alias inferred.

Element = Generator.Element

Type alias inferred.

Import import Swift

Initializers

init(_:)

Construct an instance whose generator is a copy of base.

Declaration

init(_ base: G)

Instance Methods

func generate()

Return a generator over the elements of this sequence.

Complexity: O(1)

Declaration

func generate() -> GeneratorSequence<G>
mutating func next()

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

Requires: next() has not been applied to a copy of self since the copy was made, and no preceding call to self.next() has returned nil.

Declaration

mutating func next() -> G.Element?