Struct rustc_ap_rustc_data_structures::graph::iterate::TriColorDepthFirstSearch[][src]

pub struct TriColorDepthFirstSearch<'graph, G: ?Sized> where
    G: DirectedGraph + WithNumNodes + WithSuccessors
{ /* fields omitted */ }
Expand description

A depth-first search that also tracks when all successors of a node have been examined.

This is based on the DFS described in Introduction to Algorithms (1st ed.), hereby referred to as CLR. However, we use the terminology in NodeStatus above instead of “discovered”/“finished” or “white”/“grey”/“black”. Each node begins the search with no status, becomes Visited when it is first examined by the DFS and is Settled when all nodes reachable from it have been examined. This allows us to differentiate between “tree”, “back” and “forward” edges (see TriColorVisitor::node_examined).

Unlike the pseudocode in CLR, this implementation is iterative and does not use timestamps. We accomplish this by storing Events on the stack that result in a (possible) state change for each node. A Visited event signifies that we should examine this node if it has not yet been Visited or Settled. When a node is examined for the first time, we mark it as Visited and push a Settled event for it on stack followed by Visited events for all of its predecessors, scheduling them for examination. Multiple Visited events for a single node may exist on the stack simultaneously if a node has multiple predecessors, but only one Settled event will ever be created for each node. After all Visited events for a node’s successors have been popped off the stack (as well as any new events triggered by visiting those successors), we will pop off that node’s Settled event.

Implementations

impl<G: ?Sized, 'graph> TriColorDepthFirstSearch<'graph, G> where
    G: DirectedGraph + WithNumNodes + WithSuccessors
[src]

pub fn new(graph: &'graph G) -> Self[src]

pub fn run_from<V>(self, root: G::Node, visitor: &mut V) -> Option<V::BreakVal> where
    V: TriColorVisitor<G>, 
[src]

Performs a depth-first search, starting from the given root.

This won’t visit nodes that are not reachable from root.

impl<G: ?Sized, 'graph> TriColorDepthFirstSearch<'graph, G> where
    G: DirectedGraph + WithNumNodes + WithSuccessors + WithStartNode
[src]

pub fn run_from_start<V>(self, visitor: &mut V) -> Option<V::BreakVal> where
    V: TriColorVisitor<G>, 
[src]

Performs a depth-first search, starting from G::start_node().

This won’t visit nodes that are not reachable from the start node.

Auto Trait Implementations

impl<'graph, G: ?Sized> RefUnwindSafe for TriColorDepthFirstSearch<'graph, G> where
    G: RefUnwindSafe,
    <G as DirectedGraph>::Node: RefUnwindSafe

impl<'graph, G: ?Sized> Send for TriColorDepthFirstSearch<'graph, G> where
    G: Sync,
    <G as DirectedGraph>::Node: Send

impl<'graph, G: ?Sized> Sync for TriColorDepthFirstSearch<'graph, G> where
    G: Sync,
    <G as DirectedGraph>::Node: Sync

impl<'graph, G: ?Sized> Unpin for TriColorDepthFirstSearch<'graph, G> where
    <G as DirectedGraph>::Node: Unpin

impl<'graph, G: ?Sized> UnwindSafe for TriColorDepthFirstSearch<'graph, G> where
    G: RefUnwindSafe,
    <G as DirectedGraph>::Node: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]