final def traverse[P : Parent, S, R](f: P=>S, g: (R, S) =>R, q: R=>Boolean = ...)(ts: Seq[P], r: R): R
Generic tail-recursive tree-traversal method.
Generic tail-recursive tree-traversal method.
Type parameters
P
a type which extends Parent, and thus has children of type T -- this "context bound" is implemented via a compiler-generated implicit parameter of type Parent[T].
R
the result type.
S
the return type of f, typically an Option[X] where X is something that can be combined with an R.
Value parameters
f
the map function which takes a T and produces an S for just that parent object (not its children).
g
the reduce function which accumulates the result (the accumulator is passed as its first parameter and an S value is passed as the second).
q
the quick return function which, if q(r) yields true, the method immediately returns r. Defaults to always false.
r
the current value of the result, i.e. the "accumulator".