pub trait FrontierHooks {
// Required method
fn visit_node(&mut self, node: u32, control: &mut FrontierControl<'_>);
// Provided method
fn leave_level(&mut self, level: u32, control: &mut FrontierControl<'_>) { ... }
}Expand description
The hooks of a search of your own that works off a queue of nodes, which a FrontierTraverser
runs: a type of yours implements visit_node and, if needed,
leave_level.
Java’s FrontierTraverser is an abstract class whose subclass overrides visitNode and
leaveLevel and calls the protected enqueueChildren, enqueue, isVisited, currentLevel and
stop and the protected field visited. In Rust, the state of the search stays in the
FrontierTraverser, the hooks are this trait, and the protected members are on the
FrontierControl each hook receives.
Required Methods§
Sourcefn visit_node(&mut self, node: u32, control: &mut FrontierControl<'_>)
fn visit_node(&mut self, node: u32, control: &mut FrontierControl<'_>)
Called for each node of the frontier, in the order in which the nodes entered it.
The hook puts the nodes that come next into the frontier:
enqueue_children(node) for a breadth-first search,
enqueue for single nodes, or nothing to end the search at node.
They join the next level and are visited after the rest of the current one.
Provided Methods§
Sourcefn leave_level(&mut self, level: u32, control: &mut FrontierControl<'_>)
fn leave_level(&mut self, level: u32, control: &mut FrontierControl<'_>)
Called after the last node of a level has been visited, before the first node of the next level. Does nothing unless implemented.
Nodes enqueued here join the next level, which then follows even if the completed level enqueued
nothing. level is the level just completed.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".