vg
tools for working with variation graphs
|
#include <zip_code_tree.hpp>
Public Member Functions | |
seed_iterator (size_t start_index, const ZipCodeTree &ziptree) | |
seed_iterator (const seed_iterator &other)=default | |
seed_iterator (seed_iterator &&other)=default | |
seed_iterator & | operator= (const seed_iterator &other)=default |
seed_iterator & | operator= (seed_iterator &&other)=default |
seed_iterator & | operator++ () |
bool | operator== (const seed_iterator &other) const |
bool | operator!= (const seed_iterator &other) const |
Compare for inequality. More... | |
tree_item_t | current_item () const |
What item does index point to? More... | |
vector< oriented_seed_t > | operator* () const |
size_t | get_index () const |
bool | get_right_to_left () const |
stack< size_t > | get_chain_numbers () const |
Public Attributes | |
const vector< tree_item_t > & | zip_code_tree |
A reference to the ziptree vector. More... | |
Private Attributes | |
stack< size_t > | chain_numbers |
Within each parent snarl, which chain are we in? More... | |
size_t | index |
Where we are in the stored tree. More... | |
size_t | cyclic_snarl_nestedness |
How far inside of a cyclic snarl are we? More... | |
bool | right_to_left |
vector< oriented_seed_t > | current_seeds |
Seeds at this position. More... | |
Iterator that visits seeds left to right in the tree's in-order traversal
Each seed is visited in from left to right, in the same order as get_all_seeds() would return them.
The first time any given seed is visited, right_to_left is true, indicating that a distance iterator should be set off going in the default direction of right to left.
Once the right-to-left step has been done, then the iterator decides whether to do a second, left-to-right step, with right_to_left set to false. This will happen if inside a cyclic snarl, even if not necessarily the direct parent. Calling ++() will toggle right_to_left instead of moving the internal iteration index. The next call to ++() would then reset right_to_left back to true, and finally advance the iterator rightward to the next seed.
For seeds not inside cyclic snarls, ++() will simply move rightward.
We need to traverse seeds in cyclic snarls in both directions because the chains are not necessarily traversed in a single direction, and are stored in an arbitrary orientation.
The intent of this iterator is to hide a lot of the fiddly bits required to iterate over a zip tree with cyclic and non-cyclic snarls. All a caller needs to do is
Seeds from both iterators will be automatically oriented based on the direction of traversal. That is, you can Just Trust Me (TM) for all seed orientations which iterators yield.
vg::ZipCodeTree::seed_iterator::seed_iterator | ( | size_t | start_index, |
const ZipCodeTree & | ziptree | ||
) |
Make an iterator starting from start_index until the end of the given ziptree
|
default |
|
default |
|
inline |
What item does index point to?
|
inline |
|
inline |
|
inline |
|
inline |
Compare for inequality.
|
inline |
Get the index and orientation of the seed we are currently at. Also return all other seeds on the same position
auto vg::ZipCodeTree::seed_iterator::operator++ | ( | ) |
Advance right until we hit another seed or the end Automatically handle updating chain_numbers and cyclic_snarl_nestedness
|
default |
|
default |
|
inline |
Compare for equality to see if we hit end This just trusts that the two iterators are for the same tree
|
private |
Within each parent snarl, which chain are we in?
|
private |
Seeds at this position.
|
private |
How far inside of a cyclic snarl are we?
|
private |
Where we are in the stored tree.
|
private |
Direction a distance iterator should be set off NOT the direction this iterator moves; a seed_iterator always moves left to right
const vector<tree_item_t>& vg::ZipCodeTree::seed_iterator::zip_code_tree |
A reference to the ziptree vector.