Struct mt_dom::TreePath [−][src]
Expand description
Describe the path traversal of a Node starting from the root node
The figure below shows node_idx
in a depth first traversal.
.─.
( 0 )
`-'
/ \
/ \
/ \
▼ ▼
.─. .─.
( 1 ) ( 4 )
`-' `-'
/ \ | \ '.
/ \ | \ '.
▼ ▼ | \ '.
.─. .─. ▼ ▼ ▼
( 2 ) ( 3 ) .─. .─. .─.
`─' `─' ( 5 ) ( 6 ) ( 7 )
`─' `─' `─'
The figure below shows the index of each child node relative to their parent node
.─.
( 0 )
`-'
/ \
/ \
/ \
▼ ▼
.─. .─.
( 0 ) ( 1 )
`-' `-'
/ \ | \ '.
/ \ | \ '.
▼ ▼ | \ '.
.─. .─. ▼ ▼ ▼
( 0 ) ( 1 ) .─. .─. .─.
`─' `─' ( 0 ) ( 1 ) ( 2 )
`─' `─' `─'
The equivalent idx and path are as follows:
0 = [0]
1 = [0,0]
2 = [0,0,0]
3 = [0,0,1]
4 = [0,1]
5 = [0,1,0]
6 = [0,1,1]
7 = [0,1,2]
Fields
path: Vec<usize>
an alternative path vector, where it specifies
the first element is the index of the root node which is always 0
the second element is the index of the child to traverse to and so on.
Given a DOM tree where node_idx
and path
was derived from, we can
verify that node_idx and path point to the same node.
The advantage of using this is that this doesn’t need to traverse nodes that are not
relevant. Traversal operation complexity is O(log n)
Implementations
create a TreePath with node index node_idx
and traversal path path
find the node using the path of this tree path
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for TreePath
impl UnwindSafe for TreePath
Blanket Implementations
Mutably borrows from an owned value. Read more