final class TraversalRepeatExt[A] extends AnyVal
- Alphabetic
- By Inheritance
- TraversalRepeatExt
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new TraversalRepeatExt(trav: Iterator[A])
Type Members
- type Traversal[A] = Iterator[A]
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def repeat[B >: A](repeatTraversal: (Traversal[A]) => Traversal[B])(implicit behaviourBuilder: (Builder[B]) => Builder[B] = RepeatBehaviour.noop[B]): Traversal[B]
Repeat the given traversal
Repeat the given traversal
By default it will continue repeating until there's no more results, not emit anything along the way, and use depth first search.
The @param behaviourBuilder allows you to configure end conditions (until|whilst|maxDepth), whether it should emit elements it passes by, and which search algorithm to use (depth-first or breadth-first).
Search algorithm: Depth First Search (DFS) vs Breadth First Search (BFS): DFS means the repeat step will go deep before wide. BFS does the opposite: wide before deep. For example, given the graph
L3 <- L2 <- L1 <- Center -> R1 -> R2 -> R3 -> R4
DFS will iterate the nodes in the order:
Center, L1, L2, L3, R1, R2, R3, R4
BFS will iterate the nodes in the order:
Center, L1, R1, R1, R2, L3, R3, R4
.repeat(_.out) // repeat until there's no more elements, emit nothing, use DFS .repeat(_.out)(_.maxDepth(3)) // perform exactly three repeat iterations .repeat(_.out)(_.until(_.property(Name).endsWith("2"))) // repeat until the 'Name' property ends with '2' .repeat(_.out)(_.emit) // emit everything along the way .repeat(_.out)(_.emit.breadthFirstSearch) // emit everything, use BFS .repeat(_.out)(_.emit(_.property(Name).startsWith("L"))) // emit if the 'Name' property starts with 'L'
- Note
this works for domain-specific steps as well as generic graph steps - for details please take a look at the examples in RepeatTraversalTests: both .followedBy and .out work.
- See also
RepeatTraversalTests for more detail and examples for all of the above.
Example: - def toString(): String
- Definition Classes
- Any
- val trav: Iterator[A]