[][src]Trait nannou::ui::graph::Walker

pub trait Walker<G> {
    type Index: IndexType;
    fn next(
        &mut self,
        graph: &G
    ) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>; fn next_edge(&mut self, graph: &G) -> Option<EdgeIndex<Self::Index>> { ... }
fn next_node(&mut self, graph: &G) -> Option<NodeIndex<Self::Index>> { ... }
fn count(self, graph: &G) -> usize { ... }
fn last(
        self,
        graph: &G
    ) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)> { ... }
fn last_edge(self, graph: &G) -> Option<EdgeIndex<Self::Index>> { ... }
fn last_node(self, graph: &G) -> Option<NodeIndex<Self::Index>> { ... }
fn nth(
        self,
        graph: &G,
        n: usize
    ) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)> { ... }
fn nth_edge(self, graph: &G, n: usize) -> Option<EdgeIndex<Self::Index>> { ... }
fn nth_node(self, graph: &G, n: usize) -> Option<NodeIndex<Self::Index>> { ... }
fn chain<O>(self, other: O) -> Chain<G, Self::Index, Self, O>
    where
        O: Walker<G, Index = Self::Index>
, { ... }
fn filter<P>(self, predicate: P) -> Filter<Self, P>
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn peekable(self) -> Peekable<G, Self::Index, Self> { ... }
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn skip(self, n: usize) -> Skip<G, Self::Index, Self> { ... }
fn take(self, n: usize) -> Take<G, Self::Index, Self> { ... }
fn all<P>(&mut self, graph: &G, predicate: P) -> bool
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn any<P>(&mut self, graph: &G, predicate: P) -> bool
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn find<P>(
        &mut self,
        graph: &G,
        predicate: P
    ) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn find_edge<P>(
        &mut self,
        graph: &G,
        predicate: P
    ) -> Option<EdgeIndex<Self::Index>>
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn find_node<P>(
        &mut self,
        graph: &G,
        predicate: P
    ) -> Option<NodeIndex<Self::Index>>
    where
        P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool
, { ... }
fn cycle(self) -> Cycle<G, Self::Index, Self>
    where
        Self: Clone
, { ... }
fn fold<B, F>(self, init: B, graph: &G, f: F) -> B
    where
        F: FnMut(B, &G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> B
, { ... }
fn inspect<F>(self, f: F) -> Inspect<Self, F>
    where
        F: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>)
, { ... }
fn iter(self, graph: &G) -> Iter<G, Self::Index, Self> { ... }
fn iter_weights(self, graph: &G) -> IterWeights<G, Self::Index, Self> { ... } }

A trait providing a variety of useful methods for traversing some graph type G.

Walker can be likened to the std Iterator trait. It's methods behave similarly, but it is different in that it takes a reference to some graph as an argument to its "next" method.

Walker method return types (besides the iterators) never borrow the graph. This means that we can still safely mutably borrow from the graph whilst we traverse it.

Associated Types

type Index: IndexType

The unsigned integer type used for node and edge indices.

Loading content...

Required methods

fn next(
    &mut self,
    graph: &G
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>

Fetch the EdgeIndex and NodeIndex to the next neighbour in our walk through the given Graph.

Loading content...

Provided methods

fn next_edge(&mut self, graph: &G) -> Option<EdgeIndex<Self::Index>>

The next edge in our walk for the given Graph.

fn next_node(&mut self, graph: &G) -> Option<NodeIndex<Self::Index>>

The next node in our walk for the given Graph.

fn count(self, graph: &G) -> usize

Counts all the steps in the entire walk of the given graph.

fn last(
    self,
    graph: &G
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>

Walks the whole walk until reaching and returning the last edge node pair.

fn last_edge(self, graph: &G) -> Option<EdgeIndex<Self::Index>>

Walks the whole walk until reaching and returning the last edge.

fn last_node(self, graph: &G) -> Option<NodeIndex<Self::Index>>

Walks the whole walk until reaching and returning the last node.

fn nth(
    self,
    graph: &G,
    n: usize
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)>

Walks "n" number of steps and produces the resulting edge node pair.

fn nth_edge(self, graph: &G, n: usize) -> Option<EdgeIndex<Self::Index>>

Walks "n" number of steps and produces the resulting edge.

fn nth_node(self, graph: &G, n: usize) -> Option<NodeIndex<Self::Index>>

Walks "n" number of steps and produces the resulting node.

fn chain<O>(self, other: O) -> Chain<G, Self::Index, Self, O> where
    O: Walker<G, Index = Self::Index>, 

Produces a walker that will walk the entirey of self before walking the entirey of other.

fn filter<P>(self, predicate: P) -> Filter<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Creates a walker that applies the predicate to each element returned by this walker. The only elements that will be yielded are those that make the predicate evaluate to true.

fn peekable(self) -> Peekable<G, Self::Index, Self>

Creates a walker that has a .peek(&graph) method that returns an optional next neighbor.

fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Creates a walker that invokes the predicate on elements until it returns false. Once the predicate returns false, that element and all further elements are yielded.

fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Creates a walker that yields elements so long as the predicate returns true. After the predicate returns false for the first time, no further elements will be yielded.

fn skip(self, n: usize) -> Skip<G, Self::Index, Self>

Creates a walker that skips the first n steps of this walk, and then yields all further steps.

fn take(self, n: usize) -> Take<G, Self::Index, Self>

Creates a walker that yields the first n steps of this walk.

fn all<P>(&mut self, graph: &G, predicate: P) -> bool where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Tests whether the predicate holds true for all steps in the walk.

fn any<P>(&mut self, graph: &G, predicate: P) -> bool where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Tests whether any step in the walk satisfies the given predicate.

Does not step the walker past the first found step.

fn find<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<(EdgeIndex<Self::Index>, NodeIndex<Self::Index>)> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Returns the first edge node index pair satisfying the specified predicate.

Does not consume the walker past the first found step.

fn find_edge<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<EdgeIndex<Self::Index>> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Returns the edge index satisfying the specified predicate.

Does not consume the walker past the first found step.

fn find_node<P>(
    &mut self,
    graph: &G,
    predicate: P
) -> Option<NodeIndex<Self::Index>> where
    P: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> bool

Returns the node index satisfying the specified predicate.

Does not consume the walker past the first found step.

fn cycle(self) -> Cycle<G, Self::Index, Self> where
    Self: Clone

Repeats the walker endlessly.

fn fold<B, F>(self, init: B, graph: &G, f: F) -> B where
    F: FnMut(B, &G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>) -> B, 

Performs a fold operation over the entire walker, returning the eventual state at the end of the walk.

This operation is sometimes called 'reduce' or 'inject'.

fn inspect<F>(self, f: F) -> Inspect<Self, F> where
    F: FnMut(&G, EdgeIndex<Self::Index>, NodeIndex<Self::Index>), 

Creates a walker that calls a function with a reference to each index pair before yielding them. This is often useful for debugging a walker pipeline.

fn iter(self, graph: &G) -> Iter<G, Self::Index, Self>

Converts the walker into an iterator yielding index pairs.

The returned iterator borrows the graph.

fn iter_weights(self, graph: &G) -> IterWeights<G, Self::Index, Self>

Converts the walker into an iterator yielding (&e, &n), where e is the edge weight for the next EdgeIndex and n is the node weight for the next NodeIndex.

The returned iterator borrows the graph.

Loading content...

Implementations on Foreign Types

impl Walker<Graph> for Parents<Node, Edge, u32>[src]

type Index = u32

impl Walker<Graph> for Children<Node, Edge, u32>[src]

type Index = u32

impl<G, Ix, F> Walker<G> for Recursive<G, Ix, F> where
    F: FnMut(&G, NodeIndex<Ix>) -> Option<(EdgeIndex<Ix>, NodeIndex<Ix>)>,
    Ix: IndexType
[src]

type Index = Ix

impl<G, Ix, W> Walker<G> for Skip<G, Ix, W> where
    Ix: IndexType,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<G, Ix, W, P> Walker<G> for Filter<W, P> where
    Ix: IndexType,
    P: FnMut(&G, EdgeIndex<Ix>, NodeIndex<Ix>) -> bool,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<G, Ix, W> Walker<G> for Cycle<G, Ix, W> where
    Ix: IndexType,
    W: Walker<G, Index = Ix> + Clone
[src]

type Index = Ix

impl<G, Ix, A, B> Walker<G> for Chain<G, Ix, A, B> where
    A: Walker<G, Index = Ix>,
    B: Walker<G, Index = Ix>,
    Ix: IndexType
[src]

type Index = Ix

impl<N, E, Ix> Walker<Dag<N, E, Ix>> for Children<N, E, Ix> where
    Ix: IndexType
[src]

type Index = Ix

impl<G, Ix, W> Walker<G> for Take<G, Ix, W> where
    Ix: IndexType,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<G, Ix, W, F> Walker<G> for Inspect<W, F> where
    F: FnMut(&G, EdgeIndex<Ix>, NodeIndex<Ix>),
    Ix: IndexType,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<G, Ix, W, P> Walker<G> for SkipWhile<W, P> where
    Ix: IndexType,
    P: FnMut(&G, EdgeIndex<Ix>, NodeIndex<Ix>) -> bool,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<G, Ix, W, P> Walker<G> for TakeWhile<W, P> where
    Ix: IndexType,
    P: FnMut(&G, EdgeIndex<Ix>, NodeIndex<Ix>) -> bool,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<G, Ix, W> Walker<G> for Peekable<G, Ix, W> where
    Ix: IndexType,
    W: Walker<G, Index = Ix>, 
[src]

type Index = Ix

impl<N, E, Ix> Walker<Dag<N, E, Ix>> for Parents<N, E, Ix> where
    Ix: IndexType
[src]

type Index = Ix

Loading content...

Implementors

Loading content...