pub struct NodeHierarchyRef<'a> {
pub internal: &'a [Node],
}
Expand description
The hierarchy of nodes is stored separately from the actual node content in order to save on memory, since the hierarchy can be re-used across several DOM trees even if the content changes.
Fields§
§internal: &'a [Node]
Implementations§
Source§impl<'a> NodeHierarchyRef<'a>
impl<'a> NodeHierarchyRef<'a>
pub fn from_slice(data: &'a [Node]) -> NodeHierarchyRef<'a>
pub fn len(&self) -> usize
pub fn get(&self, id: NodeId) -> Option<&Node>
pub fn linear_iter(&self) -> LinearIterator ⓘ
Sourcepub fn get_parents_sorted_by_depth(&self) -> NodeDepths
pub fn get_parents_sorted_by_depth(&self) -> NodeDepths
Returns the (depth, NodeId)
of all parent nodes (i.e. nodes that have a
first_child
), in depth sorted order, (i.e. NodeId(0)
with a depth of 0) is
the first element.
Runtime: O(n) max
Sourcepub fn subtree_len(&self, parent_id: NodeId) -> usize
pub fn subtree_len(&self, parent_id: NodeId) -> usize
Returns the number of all subtree items - runtime O(1)
Sourcepub fn get_index_in_parent(&self, node_id: NodeId) -> usize
pub fn get_index_in_parent(&self, node_id: NodeId) -> usize
Returns the index in the parent node of a certain NodeId (starts at 0, i.e. the first node has the index of 0).
Trait Implementations§
Source§impl<'a> Debug for NodeHierarchyRef<'a>
impl<'a> Debug for NodeHierarchyRef<'a>
Source§impl<'a> Hash for NodeHierarchyRef<'a>
impl<'a> Hash for NodeHierarchyRef<'a>
Source§impl<'a> Index<NodeId> for NodeHierarchyRef<'a>
impl<'a> Index<NodeId> for NodeHierarchyRef<'a>
Source§impl<'a> PartialEq for NodeHierarchyRef<'a>
impl<'a> PartialEq for NodeHierarchyRef<'a>
impl<'a> Eq for NodeHierarchyRef<'a>
impl<'a> StructuralPartialEq for NodeHierarchyRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for NodeHierarchyRef<'a>
impl<'a> RefUnwindSafe for NodeHierarchyRef<'a>
impl<'a> Send for NodeHierarchyRef<'a>
impl<'a> Sync for NodeHierarchyRef<'a>
impl<'a> Unpin for NodeHierarchyRef<'a>
impl<'a> UnwindSafe for NodeHierarchyRef<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more