Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Iterating over trees

To iterate over trees left-to-right:

    let mut tree_iterator = treeseq.tree_iterator(TreeFlags::default()).unwrap();

    while let Some(_tree) = tree_iterator.next() {
        // _tree is a tskit::Tree
    }

This API depends on traits most easily brought into scope via the crate prelude:

use tskit::prelude::*;

A next_back() function allows iteration to the next tree left of the current tree. We currently do not have an API expressing “build me an iterator starting from the rightmost tree”. Such an thing is certainly doable.