orx-selfref-col 3.2.0

SelfRefCol is a core data structure to conveniently build safe and efficient self referential collections, such as linked lists and trees.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::{MemoryPolicy, Node, SelfRefCol, Variant};
use orx_pinned_vec::PinnedVec;

impl<V, M, P> FromIterator<V::Item> for SelfRefCol<V, M, P>
where
    V: Variant,
    M: MemoryPolicy<V>,
    P: PinnedVec<Node<V>> + Default,
{
    fn from_iter<I: IntoIterator<Item = V::Item>>(iter: I) -> Self {
        let mut nodes = P::default();
        for data in iter.into_iter() {
            nodes.push(Node::new_free_node(data));
        }
        Self::with_active_nodes(nodes)
    }
}