This page provides an example of how to use the interval tree. For information on what an interval tree is and how it behaves, please see Overview over the Data Structures.
The code can also be found in the examples directory.
#include "ygg.hpp"
template<class Node>
public:
using key_type = int;
static int get_lower(const Node & node) {
return node.lower;
}
static int get_upper(const Node & node) {
return node.upper;
}
};
public:
int upper;
int lower;
std::string value;
};
int main(int argc, char **argv) {
(void)argc;
(void)argv;
MyTree t;
Node nodes[5];
for (size_t i = 0 ; i < 5 ; ++i) {
nodes[i].lower = i;
nodes[i].upper = i + 10;
nodes[i].value = std::string("The interval is [") + std::to_string(i) + std::string("]");
}
for (size_t i = 0 ; i < 5 ; ++i) {
t.insert(nodes[i]);
}
t.remove(nodes[3]);
}