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>
impl<'a, K, V> GraphElements<'a, K, V>
Sourcepub fn len(&self) -> usize
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}Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true when the collection contains key.
Sourcepub fn iter(&self) -> GraphElementIter<'a, K, V> ⓘ
pub fn iter(&self) -> GraphElementIter<'a, K, V> ⓘ
Returns key-value pairs in deterministic id order.
Sourcepub fn keys(&self) -> GraphElementKeys<'a, K, V> ⓘ
pub fn keys(&self) -> GraphElementKeys<'a, K, V> ⓘ
Returns ids in deterministic order.
Sourcepub fn values(&self) -> GraphElementValues<'a, K, V> ⓘ
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>
impl<'a, K: Clone, V: Clone> Clone for GraphElements<'a, K, V>
Source§fn clone(&self) -> GraphElements<'a, K, V>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a, K: Copy, V: Copy> Copy for GraphElements<'a, K, V>
impl<'a, K, V> Eq for GraphElements<'a, K, V>
Source§impl<'a, K, V> IntoIterator for GraphElements<'a, K, V>
impl<'a, K, V> IntoIterator for GraphElements<'a, K, V>
Source§impl<'a, 'b, K, V> PartialEq<GraphElements<'b, K, V>> for GraphElements<'a, K, V>
impl<'a, 'b, K, V> PartialEq<GraphElements<'b, K, V>> for GraphElements<'a, K, V>
Source§fn eq(&self, other: &GraphElements<'b, K, V>) -> bool
fn eq(&self, other: &GraphElements<'b, K, V>) -> bool
Tests for
self and other values to be equal, and is used by ==.Auto Trait Implementations§
impl<'a, K, V> Freeze for GraphElements<'a, K, V>
impl<'a, K, V> RefUnwindSafe for GraphElements<'a, K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<'a, K, V> Send for GraphElements<'a, K, V>
impl<'a, K, V> Sync for GraphElements<'a, K, V>
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>where
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more