• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D11-Apr-201819 21

IntervalTree.hH A D11-Apr-201811.4 KiB338294

LICENSEH A D11-Apr-20181 KiB2016

MakefileH A D11-Apr-2018893 3821

README.mdH A D11-Apr-20181.2 KiB3825

catch.hppH A D11-Apr-2018360 KiB10,2048,117

interval_tree_test.cppH A D11-Apr-20186.4 KiB189156

README.md

1# intervaltree
2
3## Overview
4
5An interval tree can be used to efficiently find a set of numeric intervals overlapping or containing another interval.
6
7This library provides a basic implementation of an interval tree using C++ templates, allowing the insertion of arbitrary types into the tree.
8
9## Usage
10
11Add `#include "IntervalTree.h"` to the source files in which you will use the interval tree.
12
13To make an IntervalTree to contain objects of class T, use:
14
15```c++
16vector<Interval<T> > intervals;
17T a, b, c;
18intervals.push_back(Interval<T>(2, 10, a));
19intervals.push_back(Interval<T>(3, 4, b));
20intervals.push_back(Interval<T>(20, 100, c));
21IntervalTree<T> tree;
22tree = IntervalTree<T>(intervals);
23```
24
25Now, it's possible to query the tree and obtain a set of intervals which are contained within the start and stop coordinates.
26
27```c++
28vector<Interval<T> > results;
29tree.findContained(start, stop, results);
30cout << "found " << results.size() << " overlapping intervals" << endl;
31```
32
33The function IntervalTree::findOverlapping provides a method to find all those intervals which are contained or partially overlap the interval (start, stop).
34
35### Author: Erik Garrison <erik.garrison@gmail.com>
36
37### License: MIT
38