File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,14 @@ impl<'treeseq> LLTree<'treeseq> {
217217 pub fn roots ( & self ) -> impl Iterator < Item = NodeId > + ' _ {
218218 NodeIteratorAdapter ( RootIterator :: new ( self ) )
219219 }
220+
221+ pub fn sample_nodes ( & self ) -> & [ NodeId ] {
222+ assert ! ( !self . as_ptr( ) . is_null( ) ) ;
223+ // SAFETY: self ptr is not null and the tree is initialized
224+ let num_samples =
225+ unsafe { bindings:: tsk_treeseq_get_num_samples ( self . as_ref ( ) . tree_sequence ) } ;
226+ super :: generate_slice ( self . as_ref ( ) . samples , num_samples)
227+ }
220228}
221229
222230// Trait defining iteration over nodes.
Original file line number Diff line number Diff line change @@ -176,6 +176,11 @@ impl<'treeseq> Tree<'treeseq> {
176176 self . roots ( ) . collect :: < Vec :: < _ > > ( )
177177 }
178178
179+ /// Get the list of sample nodes as a slice.
180+ pub fn sample_nodes ( & self ) -> & [ NodeId ] {
181+ self . inner . sample_nodes ( )
182+ }
183+
179184 /// Return an [`Iterator`] over all nodes in the tree.
180185 ///
181186 /// # Parameters
You can’t perform that action at this time.
0 commit comments