vg
tools for working with variation graphs
Public Member Functions | Public Attributes | List of all members
vg::BitStringTree< Item >::TreeNode Struct Reference

#include <stream_index.hpp>

Public Member Functions

void insert (const BitString &key, const Item &value)
 
bool traverse_up (const BitString &key, const function< bool(const Item &)> &iteratee) const
 
bool traverse_in_order (const BitString &low, const BitString &high, const function< bool(const Item &)> &iteratee) const
 

Public Attributes

BitString prefix
 Each TreeNode represents a prefix over its parent. More...
 
unique_ptr< TreeNodechildren [2]
 
Item content
 Each TreeNode also may hold an item record. More...
 
bool has_content = false
 This is set if we actually have one. More...
 

Member Function Documentation

◆ insert()

template<typename Item >
void vg::BitStringTree< Item >::TreeNode::insert ( const BitString key,
const Item &  value 
)

Insert the given item at or under this node. Its key must have had our prefix already removed from it.

◆ traverse_in_order()

template<typename Item >
bool vg::BitStringTree< Item >::TreeNode::traverse_in_order ( const BitString low,
const BitString high,
const function< bool(const Item &)> &  iteratee 
) const

Iterate over elements in the tree with an in-order traversal between the two given keys, inclusive. Low and high have already had this node's prefix removed.

Define a function to process each child. Returns false if we stop early

◆ traverse_up()

template<typename Item >
bool vg::BitStringTree< Item >::TreeNode::traverse_up ( const BitString key,
const function< bool(const Item &)> &  iteratee 
) const

Search down to the node that corresponds to the given key, or where it would be. Call the iteratee for that node and every parent, from bottom to top, until the iteratee returns false. If not found, do not call the iteratee. Retruns true if the iteratee did not ask to stop, and false otherwise. The key will have already had this node's prefix removed.

Member Data Documentation

◆ children

template<typename Item >
unique_ptr<TreeNode> vg::BitStringTree< Item >::TreeNode::children[2]

Each TreeNode holds a 0 child and a 1 child, at most Their prefixes say what full prefixes they actually correspond to

◆ content

template<typename Item >
Item vg::BitStringTree< Item >::TreeNode::content

Each TreeNode also may hold an item record.

◆ has_content

template<typename Item >
bool vg::BitStringTree< Item >::TreeNode::has_content = false

This is set if we actually have one.

◆ prefix

template<typename Item >
BitString vg::BitStringTree< Item >::TreeNode::prefix

Each TreeNode represents a prefix over its parent.


The documentation for this struct was generated from the following file: