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