geny
package geny
- Alphabetic
- Public
- All
Type Members
-
trait
Generator
[+A] extends AnyRef
Provides the
geny.Gen
data type, A Generator of elements of type A.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.