pub struct NodeList<'gc> { /* private fields */ }Expand description
An ordered list of nodes used as a property in the AST.
Implemented as a linked list internally to avoid extra overhead that would
exist if it were to allocate a Vec or some other structure that required
allocating on the native heap.
Because this is just a Copy head pointer into context-allocated
NodeListElements (juno model), it implements Copy much like any other
pointer/reference, allowing the user to handle it much like &Node in many
cases. Empty == null head.
Implementations§
Source§impl<'gc> NodeList<'gc>
impl<'gc> NodeList<'gc>
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create a new empty list. Guaranteed to be fast, performs no allocations.
Sourcepub fn from_iter<'a, I: IntoIterator<Item = &'a Node<'a>>>(
lock: &'a GCLock<'_, '_>,
nodes: I,
) -> NodeList<'a>
pub fn from_iter<'a, I: IntoIterator<Item = &'a Node<'a>>>( lock: &'a GCLock<'_, '_>, nodes: I, ) -> NodeList<'a>
Connect the provided pre-existing nodes into a NodeList via iteration.
NodeList doesn’t implement FromIterator directly due to the GCLock
requirement.
Sourcepub fn iter(self) -> NodeListIter<'gc> ⓘ
pub fn iter(self) -> NodeListIter<'gc> ⓘ
Iterate the list front to back. Cost: O(1) to start, O(1) per step.