A Visitor accumulates (V, Option[R]) pairs into a journal J as it traverses a structure.
Two members provide access to the accumulated journal:
journal — the raw journal value of type J; used internally by concrete implementations (e.g. JournaledVisitor.copy(journal = ...)) where the specific J type must be visible for polymorphic copying.
result — a public alias for journal, defaulting to journal; intended as the external API for consumers of a completed traversal. A concrete implementation could override result to apply post-processing (e.g. reversing a ListJournal) without affecting the internal journal.
Two events are distinguished:
visit(v) — called when a vertex is settled (dequeued/popped and processed). Records (v, ev.evaluate(v)) in the journal.
discover(v, cameFrom) — called when a vertex is first seen as a neighbour of cameFrom, before it is added to the frontier. Default implementation is a no-op; override in concrete implementations that track came-from pointers.
Type parameters
J
the journal type (must be Appendable of (V, Option[R]))
Retrieves the journal J that accumulates pairs of (V, Option[R]) as a result of traversing a structure. The journal is an appendable collection used for recording events during the traversal.
Retrieves the journal J that accumulates pairs of (V, Option[R]) as a result of traversing a structure. The journal is an appendable collection used for recording events during the traversal.
Attributes
Returns
the journal of type J containing the accumulated data.
Visits a vertex v, evaluates it using the implicit Evaluable instance, and records the result in the journal. The visitor is returned after the operation with an updated state.
Visits a vertex v, evaluates it using the implicit Evaluable instance, and records the result in the journal. The visitor is returned after the operation with an updated state.
Value parameters
ev
the implicit Evaluable instance to extract a result of type R from the vertex v.
v
the vertex to be visited.
Attributes
Returns
the updated Visitor after the vertex is processed, with its journal containing the new (v, Option[R]) entry.