Skip to main content

GraphElements

Struct GraphElements 

Source
pub struct GraphElements<'a, K, V> { /* private fields */ }
Expand description

Read-only view over one graph element collection.

This keeps Graph’s public API from committing callers to its storage type while preserving the common map-like read operations adapters need for deterministic traversal and lookup.

Implementations§

Source§

impl<'a, K, V> GraphElements<'a, K, V>

Source

pub fn len(&self) -> usize

Returns the number of elements.

Examples found in repository?
examples/build_graph.rs (line 43)
32fn main() {
33    let node_id = NodeId::from_u128(2);
34    let mut graph = Graph::new(GraphId::from_u128(1));
35
36    let mut tx = GraphTransaction::new().with_label("add source node");
37    tx.push(GraphOp::AddNode {
38        id: node_id,
39        node: make_node("demo.source", 10.0, 20.0),
40    });
41    tx.apply_to(&mut graph).expect("transaction applies");
42
43    assert_eq!(graph.nodes().len(), 1);
44    assert_eq!(
45        graph.nodes()[&node_id].kind,
46        NodeKindKey::new("demo.source")
47    );
48}
Source

pub fn is_empty(&self) -> bool

Returns true when this collection has no elements.

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q> + Ord, Q: Ord + ?Sized,

Returns true when the collection contains key.

Source

pub fn get<Q>(&self, key: &Q) -> Option<&'a V>
where K: Borrow<Q> + Ord, Q: Ord + ?Sized,

Returns an element by id.

Source

pub fn iter(&self) -> GraphElementIter<'a, K, V>

Returns key-value pairs in deterministic id order.

Source

pub fn keys(&self) -> GraphElementKeys<'a, K, V>

Returns ids in deterministic order.

Source

pub fn values(&self) -> GraphElementValues<'a, K, V>

Returns element values in deterministic id order.

Trait Implementations§

Source§

impl<'a, K: Clone, V: Clone> Clone for GraphElements<'a, K, V>

Source§

fn clone(&self) -> GraphElements<'a, K, V>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, K: Copy, V: Copy> Copy for GraphElements<'a, K, V>

Source§

impl<'a, K: Debug, V: Debug> Debug for GraphElements<'a, K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, K, V> Eq for GraphElements<'a, K, V>
where K: Ord + Eq, V: Eq,

Source§

impl<'a, K, V> Index<&K> for GraphElements<'a, K, V>
where K: Ord,

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, key: &K) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, K, V> IntoIterator for GraphElements<'a, K, V>

Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = GraphElementIter<'a, K, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, 'b, K, V> PartialEq<GraphElements<'b, K, V>> for GraphElements<'a, K, V>
where K: Ord + PartialEq, V: PartialEq,

Source§

fn eq(&self, other: &GraphElements<'b, K, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'a, K, V> Freeze for GraphElements<'a, K, V>

§

impl<'a, K, V> RefUnwindSafe for GraphElements<'a, K, V>

§

impl<'a, K, V> Send for GraphElements<'a, K, V>
where K: Sync, V: Sync,

§

impl<'a, K, V> Sync for GraphElements<'a, K, V>
where K: Sync, V: Sync,

§

impl<'a, K, V> Unpin for GraphElements<'a, K, V>

§

impl<'a, K, V> UnsafeUnpin for GraphElements<'a, K, V>

§

impl<'a, K, V> UnwindSafe for GraphElements<'a, K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.