File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed
Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,42 @@ impl<'treeseq> LLTree<'treeseq> {
9696 )
9797 }
9898
99+ pub fn right_sib ( & self , u : NodeId ) -> Option < NodeId > {
100+ super :: tsk_column_access :: < NodeId , _ , _ , _ > (
101+ u,
102+ self . as_ref ( ) . right_sib ,
103+ unsafe {
104+ self . as_ref ( )
105+ . tree_sequence
106+ . as_ref ( )
107+ . unwrap ( )
108+ . tables
109+ . as_ref ( )
110+ }
111+ . unwrap ( )
112+ . nodes
113+ . num_rows ,
114+ )
115+ }
116+
117+ pub fn left_child ( & self , u : NodeId ) -> Option < NodeId > {
118+ super :: tsk_column_access :: < NodeId , _ , _ , _ > (
119+ u,
120+ self . as_ref ( ) . left_child ,
121+ unsafe {
122+ self . as_ref ( )
123+ . tree_sequence
124+ . as_ref ( )
125+ . unwrap ( )
126+ . tables
127+ . as_ref ( )
128+ }
129+ . unwrap ( )
130+ . nodes
131+ . num_rows ,
132+ )
133+ }
134+
99135 pub fn right_child ( & self , u : NodeId ) -> Option < NodeId > {
100136 super :: tsk_column_access :: < NodeId , _ , _ , _ > (
101137 u,
@@ -169,6 +205,10 @@ impl<'treeseq> LLTree<'treeseq> {
169205 }
170206 }
171207 }
208+
209+ pub fn children ( & self , u : NodeId ) -> impl Iterator < Item = NodeId > + ' _ {
210+ NodeIteratorAdapter ( ChildIterator :: new ( self , u) )
211+ }
172212}
173213
174214// Trait defining iteration over nodes.
Original file line number Diff line number Diff line change @@ -160,6 +160,15 @@ impl<'treeseq> Tree<'treeseq> {
160160 ) -> Box < dyn Iterator < Item = NodeId > + ' _ > {
161161 self . inner . traverse_nodes ( order)
162162 }
163+
164+ /// Return an [`Iterator`] over the children of node `u`.
165+ /// # Returns
166+ ///
167+ /// * `Some(iterator)` if `u` is valid
168+ /// * `None` otherwise
169+ pub fn children < N : Into < NodeId > + Copy > ( & self , u : N ) -> impl Iterator < Item = NodeId > + ' _ {
170+ self . inner . children ( u. into ( ) )
171+ }
163172}
164173
165174impl < ' ts > streaming_iterator:: StreamingIterator for Tree < ' ts > {
You can’t perform that action at this time.
0 commit comments