trait Generator[+A] extends AnyRef
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-based
hasNext
and next: T
methods, the core is based around the push-based
generate
method. generate
is basically an extra-customizable version of
foreach
, 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 the generate
call is made.
Transformations on a Generator are lazy: calling methods like filter
or map
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 like
generate
/foreach
/find
, or the "Conversion" methods like toArray
or
similar.
generate
takes a function returning Gen.Action
rather that
Unit
. 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.
- Alphabetic
- By Inheritance
- Generator
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
- abstract def generate(handleItem: (A) => Action): Action
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.- handleItem
How to handle a single item: performs any desired side effects, and returns a Generator.Action that determines how to continue the enumeration.
- returns
an integer stating how many skipped elements from the
startingSkipped
input remain to be skipped after thisgenerate
call has completed.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- def ++[B >: A](other: Generator[B]): Generator[B]
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def collect[B](func: PartialFunction[A, B]): Generator[B]
- def collectFirst[B](func: PartialFunction[A, B]): Option[B]
- def contains(a: Any): Boolean
- def count(f: (A) => Boolean = _ => true): Int
- def drop(n: Int): Generator[A]
- def dropWhile(pred: (A) => Boolean): Generator[A]
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def exists(f: (A) => Boolean): Boolean
- def filter(pred: (A) => Boolean): Generator[A]
- def find(f: (A) => Boolean): Option[A]
- def flatMap[B](func: (A) => Generator[B]): Generator[B]
- def flatten[V](implicit f: (A) => Generator[V]): Generator[V]
- def fold[B](start: B)(f: (B, A) => B): B
- def foldLeft[B](start: B)(f: (B, A) => B): B
- def forall(f: (A) => Boolean): Boolean
- def foreach(f: (A) => Unit): Unit
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def head: A
- def headOption: Option[A]
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](func: (A) => B): Generator[B]
- def max[B >: A](implicit cmp: Ordering[B]): A
- def maxBy[B](f: (A) => B)(implicit cmp: Ordering[B]): A
- def min[B >: A](implicit cmp: Ordering[B]): A
- def minBy[B](f: (A) => B)(implicit cmp: Ordering[B]): A
- def mkString: String
- def mkString(sep: String): String
- def mkString(start: String, sep: String, end: String): String
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def product[B >: A](implicit num: Numeric[B]): B
- def reduce[B >: A](f: (B, A) => B): B
- def reduceLeft[B >: A](f: (B, A) => B): B
- def slice(start: Int, end: Int): Generator[A]
- def sum[B >: A](implicit num: Numeric[B]): B
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def take(n: Int): Generator[A]
- def takeWhile(pred: (A) => Boolean): Generator[A]
- def toArray[B >: A](implicit arg0: ClassTag[B]): Array[B]
- def toBuffer[B >: A]: Buffer[B]
- def toList: List[A]
- def toSeq: Seq[A]
- def toSet[B >: A]: Set[B]
- def toString(): String
- Definition Classes
- AnyRef → Any
- def toVector: Vector[A]
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withFilter(pred: (A) => Boolean): Generator[A]
- def zip[B](other: Iterable[B]): Generator[(A, B)]
- def zipWithIndex: Generator[(A, Int)]