-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(from_readme) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
add_executable(from_readme main.cpp) | ||
target_link_libraries(from_readme interval-tree) | ||
|
||
set_target_properties(from_readme | ||
PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/interval_tree/examples" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// #include <interval-tree/draw.hpp> // to draw tree. this is not header only anymore. | ||
#include <interval-tree/interval_tree.hpp> | ||
|
||
int main() | ||
{ | ||
using namespace lib_interval_tree; | ||
|
||
// interval_tree<interval<int>>; // closed by default | ||
// interval_tree<interval<int, open>>; | ||
// interval_tree<interval<int, closed>>; | ||
// interval_tree<interval<int, left_open>>; | ||
// interval_tree<interval<int, right_open>>; | ||
// interval_tree<interval<int, closed_adjacent>>; // counts adjacent intervals as overlapping | ||
interval_tree_t<int> tree; | ||
|
||
tree.insert(make_safe_interval<int>(21, 16)); // make_safe_interval swaps low and high if not in right order. | ||
tree.insert({8, 9}); | ||
tree.insert({25, 30}); | ||
tree.insert({5, 8}); | ||
tree.insert({15, 23}); | ||
tree.insert({17, 19}); | ||
tree.insert({26, 26}); | ||
tree.insert({0, 3}); | ||
tree.insert({6, 10}); | ||
tree.insert({19, 20}); | ||
|
||
tree.deoverlap(); | ||
|
||
for (auto const& i : tree) | ||
{ | ||
std::cout << "[" << i.low() << ", " << i.high() << "]\n"; | ||
} | ||
|
||
using lib_interval_tree::open; | ||
// dynamic has some logic overhead. | ||
interval_tree<interval<int, dynamic>> dynamicIntervals; | ||
dynamicIntervals.insert({0, 1, interval_border::closed, interval_border::open}); | ||
dynamicIntervals.insert({7, 5, interval_border::open, interval_border::closed_adjacent}); | ||
} |