pub struct NodeHierarchy {
pub internal: Vec<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: Vec<Node>
Implementations§
Source§impl NodeHierarchy
impl NodeHierarchy
pub const fn new(data: Vec<Node>) -> Self
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 Clone for NodeHierarchy
impl Clone for NodeHierarchy
Source§fn clone(&self) -> NodeHierarchy
fn clone(&self) -> NodeHierarchy
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for NodeHierarchy
impl Debug for NodeHierarchy
Source§impl Default for NodeHierarchy
impl Default for NodeHierarchy
Source§fn default() -> NodeHierarchy
fn default() -> NodeHierarchy
Returns the “default value” for a type. Read more
Source§impl Hash for NodeHierarchy
impl Hash for NodeHierarchy
Source§impl Index<NodeId> for NodeHierarchy
impl Index<NodeId> for NodeHierarchy
Source§impl IndexMut<NodeId> for NodeHierarchy
impl IndexMut<NodeId> for NodeHierarchy
Source§impl PartialEq for NodeHierarchy
impl PartialEq for NodeHierarchy
impl Eq for NodeHierarchy
impl StructuralPartialEq for NodeHierarchy
Auto Trait Implementations§
impl Freeze for NodeHierarchy
impl RefUnwindSafe for NodeHierarchy
impl Send for NodeHierarchy
impl Sync for NodeHierarchy
impl Unpin for NodeHierarchy
impl UnwindSafe for NodeHierarchy
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)