Skip to content

Commit 4fdebe8

Browse files
committed
more
1 parent f14ec57 commit 4fdebe8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/sys/tree.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

src/trees/tree.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)