Struct bag::GraphStore [] [src]

pub struct GraphStore<T> { /* fields omitted */ }

A generic container for a graph

A GraphStore<T> is a struct that contains the actual graph representation. Try not to loose it.

Example

use bag::{GraphStore, Node};
let root_node = Node::new("String".to_string());
let (mut graph, root_node_id) = GraphStore::new(root_node);
assert_eq!(*graph.get(root_node_id).unwrap().parent(), None);

Methods

impl<T> GraphStore<T>
[src]

[src]

Constructs a new GraphStore<T> and handle to the root Node<T>

Accepts a root node of type Node<T> (this is the only node held in the graph that can have a None for it's parent (though it may have a Some(parent) if the graph is cyclic at the root.

[src]

Returns an option with a reference to the node represented by NodeID, if found

get searches the GraphStore<T> for a node with the NodeID passed as node. If it is found, a non-mutable reference to it is returned in a Some, otherwise a None is returned.

[src]

Returns an option with a mutable reference to the node represented by NodeID, if found

get_mut searches the GraphStore<T> for a node with the NodeID passed as node. If it is found, a mutable reference to it is returned in a Some, otherwise a None is returned.

[src]

Returns an option with a reference to a Vec of a Node<T>s sublings, if found

get_siblings_id searches the GraphStore<T> for a node with the NodeID passed as node. If it is found, a non-mutable reference to it's parent's children is returned in a Some, otherwise a None is returned. Note that node is itself included in the returned Vec<NodeID>.

[src]

Inserts a node into the graph

insert_child accepts a parent NodeID and takes ownership of an inserted Node<T>. If the parent NodeID is valid, the Node<T> is inserted into the graph. The child's parent pointer is then set to the NodeID of the parent, and the parent's child Vec<NodeID is updated to include the NodeID of the child. Returns a Result<NodeID, &'static str representing success or failure of the insertion.

Trait Implementations

impl<T: Debug> Debug for GraphStore<T>
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<T> Send for GraphStore<T> where
    T: Send

impl<T> Sync for GraphStore<T> where
    T: Sync