struct GeneratorSequence<G : GeneratorType>

A sequence built around a generator of type G.

Useful mostly to recover the ability to use, 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



Construct an instance whose generator is a copy of base.


init(_ base: G)

Instance Methods

func generate()

Return a generator over the elements of this sequence.

Complexity: O(1)


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 has returned nil.


mutating func next() -> G.Element?