-
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.
Merge pull request #35 from 5cript/feat/interval-kinds
Made interval types meaningful.
- Loading branch information
Showing
10 changed files
with
1,342 additions
and
156 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}); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,25 @@ | ||
#pragma once | ||
|
||
#if defined(__cpp_concepts) && __cpp_concepts >= 202002L | ||
# define LIB_INTERVAL_TREE_CONCEPTS | ||
// define LIB_INTERVAL_TREE_CONCEPTS to override the concepts feature test | ||
#ifndef LIB_INTERVAL_TREE_CONCEPTS | ||
# if defined(__cpp_concepts) && __cpp_concepts >= 202002L | ||
# define LIB_INTERVAL_TREE_CONCEPTS | ||
# endif | ||
#endif | ||
|
||
namespace lib_interval_tree | ||
{ | ||
} | ||
// define LIB_INTERVAL_TREE_DEPRECATED if __attribute__((deprecated)) is not supported | ||
#ifndef LIB_INTERVAL_TREE_DEPRECATED | ||
# if __has_cpp_attribute(depreacted) | ||
# define LIB_INTERVAL_TREE_DEPRECATED [[deprecated]] | ||
# else | ||
# define LIB_INTERVAL_TREE_DEPRECATED __attribute__((deprecated)) | ||
# endif | ||
#endif | ||
|
||
#ifndef LIB_INTERVAL_TREE_FALLTHROUGH | ||
# if __has_cpp_attribute(fallthrough) | ||
# define LIB_INTERVAL_TREE_FALLTHROUGH [[fallthrough]] | ||
# else | ||
# define LIB_INTERVAL_TREE_FALLTHROUGH __attribute__((fallthrough)) | ||
# endif | ||
#endif |
Oops, something went wrong.