The core abstract method that defines the Generator trait.
The core abstract method that defines the Generator trait. It is
essentially the same as .foreach
, but with additional configurability.
How to handle a single item: performs any desired side effects, and returns a Generator.Action that determines how to continue the enumeration.
an integer stating how many skipped elements from the
startingSkipped
input remain to be skipped after this
generate
call has completed.
Provides the
geny.Gen
data type, A Generator of elements of type A.Generator is basically the inverse of a
scala.Iterator
: instead of the core functionality being the pull-basedhasNext
andnext: T
methods, the core is based around the push-basedgenerate
method.generate
is basically an extra-customizable version offoreach
, which allows the person calling it to provide basic control-flow instructions to the upstream Gens.Unlike a
scala.Iterator
, subclasses of Generator can guarantee any clean up logic is performed by placing it after thegenerate
call is made.Transformations on a Generator are lazy: calling methods like
filter
ormap
do not evaluate the entire Gen, but instead construct a new Gen that delegates to the original. The only methods that evaluate the Generator are the "Action" methods likegenerate
/foreach
/find
, or the "Conversion" methods liketoArray
or similar.generate
takes a function returningGen.Action
rather thatUnit
. This allows a downstream Gen to provide basic control commands to the upstream Gens: i.e. Generator.End to cease enumeration of the upstream Gen. This allows it to avoid traversing and processing elements that the downstream Gen doesn't want/need to see anyway.