{"id":43266951,"url":"https://github.com/5cript/interval-tree","last_synced_at":"2026-02-01T15:13:01.763Z","repository":{"id":46917127,"uuid":"86068065","full_name":"5cript/interval-tree","owner":"5cript","description":"A C++ header only interval tree implementation.","archived":false,"fork":false,"pushed_at":"2025-08-29T23:33:32.000Z","size":206,"stargazers_count":68,"open_issues_count":0,"forks_count":18,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-08-30T01:12:43.548Z","etag":null,"topics":["cpp11","interval","interval-tree","intervals","overlap","red-black-tree"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/5cript.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-03-24T12:56:50.000Z","updated_at":"2025-08-29T23:26:02.000Z","dependencies_parsed_at":"2025-08-30T01:09:55.513Z","dependency_job_id":"3e14556e-bb1b-494e-9bec-acdd590f6109","html_url":"https://github.com/5cript/interval-tree","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/5cript/interval-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cript%2Finterval-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cript%2Finterval-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cript%2Finterval-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cript%2Finterval-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/5cript","download_url":"https://codeload.github.com/5cript/interval-tree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5cript%2Finterval-tree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28980858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T13:38:33.235Z","status":"ssl_error","status_checked_at":"2026-02-01T13:38:32.912Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp11","interval","interval-tree","intervals","overlap","red-black-tree"],"created_at":"2026-02-01T15:13:01.118Z","updated_at":"2026-02-01T15:13:01.758Z","avatar_url":"https://github.com/5cript.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# interval-tree\n\nA C++ header only interval tree implementation, which takes a red black tree as its base to inhibit degeneration to linked lists.\n\n- [Interval Tree](#interval-tree)\n  - [How an interval tree looks like:](#how-an-interval-tree-looks-like)\n  - [Example](#example)\n  - [Compile \u0026 Run Testing](#compile--run-testing)\n  - [Free Functions](#free-functions)\n  - [Members of IntervalTree](#members-of-intervaltree)\n  - [Members of Interval](#members-of-interval)\n\n## How an interval tree looks like:\n![ExampleTree](https://cloud.githubusercontent.com/assets/6238896/24608762/36422d7c-1878-11e7-9c5c-a45bdcd6e187.png)\n\n## Example\n```C++\n// #include \u003cinterval-tree/draw.hpp\u003e // to draw tree. this is not header only anymore.\n#include \u003cinterval-tree/interval_tree.hpp\u003e\n\nint main()\n{\n  using namespace lib_interval_tree;\n\n  // interval_tree\u003cinterval\u003cint\u003e\u003e; // closed by default\n  // interval_tree\u003cinterval\u003cint, open\u003e\u003e;\n  // interval_tree\u003cinterval\u003cint, closed\u003e\u003e;\n  // interval_tree\u003cinterval\u003cint, left_open\u003e\u003e;\n  // interval_tree\u003cinterval\u003cint, right_open\u003e\u003e;\n  // interval_tree\u003cinterval\u003cint, closed_adjacent\u003e\u003e; // counts adjacent intervals as overlapping\n  interval_tree_t\u003cint\u003e tree;\n\n  tree.insert(make_safe_interval\u003cint\u003e(21, 16)); // make_safe_interval swaps low and high if not in right order.\n  tree.insert({8, 9});\n  tree.insert({25, 30});\n  tree.insert({5, 8});\n  tree.insert({15, 23});\n  tree.insert({17, 19});\n  tree.insert({26, 26});\n  tree.insert({0, 3});\n  tree.insert({6, 10});\n  tree.insert({19, 20});\n\n  tree.deoverlap();\n\n  for (auto const\u0026 i : tree)\n  {\n    std::cout \u003c\u003c \"[\" \u003c\u003c i.low() \u003c\u003c \", \" \u003c\u003c i.high() \u003c\u003c \"]\\n\";\n  }\n\n  // dynamic has some logic overhead.\n  interval_tree\u003cinterval\u003cint, dynamic\u003e\u003e dynamicIntervals;\n  dynamicIntervals.insert({0, 1, interval_border::closed, interval_border::open});\n  dynamicIntervals.insert({7, 5, interval_border::open, interval_border::closed_adjacent});\n}\n```\n\n## Compile \u0026 Run Testing\nHaving googletest (find here on github) installed / built is a requirement to run the tests.\nCreate a build folder, navigate there, run cmake and build the tree-tests target.\nYou might have to adapt the linker line for gtest, if you built it yourself and didn't install it into your system.\nIf you want to generate the pretty drawings, install cairo, pull the submodule and pass INT_TREE_DRAW_EXAMPLES=on to the cmake command line to generate a drawings/make_drawings executeable.\n\nSome features of this library require the presence of an optional type.\nIf you are using C++17 and up, it will be std::optional.\nOtherwise you can specify INTERVAL_TREE_HAVE_BOOST_OPTIONAL to use boost::optional.\nAnd if neither, a reduced version of optional is provided in the library, not perfectly exchangeable with std::optional, but sufficient for the library to work.\n\n## Draw Dot Graph\nThis draws a dot graph of the tree:\n```c++\n#include \u003cinterval-tree/interval_tree.hpp\u003e\n#include \u003cinterval-tree/dot_graph.hpp\u003e\n\nint main()\n{\n    using namespace lib_interval_tree;\n    interval_tree_t\u003cint\u003e tree;\n\n    tree.insert(make_safe_interval\u003cint\u003e(21, 16)); // make_safe_interval swaps low and high if not in right order.\n    tree.insert({8, 9});\n    tree.insert({25, 30});\n    tree.insert({5, 8});\n    tree.insert({15, 23});\n    tree.insert({17, 19});\n    tree.insert({26, 26});\n    tree.insert({0, 3});\n    tree.insert({6, 10});\n    tree.insert({19, 20});\n\n    draw_dot_graph(\n        std::cout,\n        tree,\n        {\n            // digraph or graph?\n            .digraph = true,\n\n            // graph name\n            .name = \"G\",\n\n            // extra node attributes\n            .extra_node_attributes = {\"color=red\"},\n\n            // extra graph statements\n            .extra_statements = {\"rankdir=LR\"},\n\n            // put space after comma of interval label? (a,b) vs (a, b)\n            .space_after_comma = false,\n\n            // left brace override enabled if not 0, otherwise determined from interval kind\n            .left_brace = '\\0',\n\n            // right brace override enabled if not 0, otherwise determined from interval kind\n            .right_brace = '\\0',\n\n            // edge attributes\n            .edge_attributes = {\"color=blue\"},\n\n            // indent characters\n            .indent = \"\\t\",\n        }\n    );\n}\n```\n\n## Free Functions\n### interval\u003cNumericT, Kind\u003e make_safe_interval(NumericT border1, NumericT border2)\nCreates an interval where the borders are sorted so the lower border is the first one.\n\n### draw_dot_graph(std::ostream\u0026 os, interval_tree_t\u003cInterval\u003e const\u0026 tree, DrawOptions const\u0026 options)\nDraws a dot graph of the interval tree to the output stream.\nOptions are:\n- digraph: bool\n- name: std::string\n- extra_node_attributes: std::vector\\\u003cstd::string\\\u003e\n- extra_statements: std::vector\\\u003cstd::string\\\u003e\n- space_after_comma: bool\n- left_brace: char (0 = ignored, std::optional is c++17)\n- right_brace: char (0 = ignored, std::optional is c++17)\n- edge_attributes: std::vector\\\u003cstd::string\\\u003e\n- indent: std::string\n\n## Members of IntervalTree\u003cInterval\u003e\n\n- [interval-tree](#interval-tree)\n  - [How an interval tree looks like:](#how-an-interval-tree-looks-like)\n  - [Example](#example)\n  - [Compile \\\u0026 Run Testing](#compile--run-testing)\n  - [Draw Dot Graph](#draw-dot-graph)\n  - [Free Functions](#free-functions)\n    - [interval\\\u003cNumericT, Kind\\\u003e make\\_safe\\_interval(NumericT border1, NumericT border2)](#intervalnumerict-kind-make_safe_intervalnumerict-border1-numerict-border2)\n    - [draw\\_dot\\_graph(std::ostream\\\u0026 os, interval\\_tree\\_t const\\\u0026 tree, DrawOptions const\\\u0026 options)](#draw_dot_graphstdostream-os-interval_tree_t-const-tree-drawoptions-const-options)\n  - [Members of IntervalTree](#members-of-intervaltree)\n    - [iterator insert(interval\\_type const\\\u0026 ival)](#iterator-insertinterval_type-const-ival)\n      - [Parameters](#parameters)\n    - [iterator insert\\_overlap(interval\\_type const\\\u0026 ival, bool, bool)](#iterator-insert_overlapinterval_type-const-ival-bool-bool)\n      - [Parameters](#parameters-1)\n    - [iterator erase(iterator iter)](#iterator-eraseiterator-iter)\n      - [Parameters](#parameters-2)\n    - [size\\_type size() const](#size_type-size-const)\n    - [(const)iterator find(interval\\_type const\\\u0026 ival)](#constiterator-findinterval_type-const-ival)\n      - [Parameters](#parameters-3)\n    - [(const)iterator find(interval\\_type const\\\u0026 ival, CompareFunctionT const\\\u0026 compare)](#constiterator-findinterval_type-const-ival-comparefunctiont-const-compare)\n      - [Parameters](#parameters-4)\n    - [(const)iterator find\\_all(interval\\_type const\\\u0026 ival, OnFindFunctionT const\\\u0026 on\\_find)](#constiterator-find_allinterval_type-const-ival-onfindfunctiont-const-on_find)\n      - [Parameters](#parameters-5)\n      - [Example](#example-1)\n    - [(const)iterator find\\_all(interval\\_type const\\\u0026 ival, OnFindFunctionT const\\\u0026 on\\_find, CompareFunctionT const\\\u0026 compare)](#constiterator-find_allinterval_type-const-ival-onfindfunctiont-const-on_find-comparefunctiont-const-compare)\n      - [Parameters](#parameters-6)\n    - [(const)iterator find\\_next\\_in\\_subtree(iterator from, interval\\_type const\\\u0026 ival)](#constiterator-find_next_in_subtreeiterator-from-interval_type-const-ival)\n      - [Parameters](#parameters-7)\n    - [(const)iterator find\\_next\\_in\\_subtree(iterator from, interval\\_type const\\\u0026 ival, CompareFunctionT const\\\u0026 compare)](#constiterator-find_next_in_subtreeiterator-from-interval_type-const-ival-comparefunctiont-const-compare)\n      - [Parameters](#parameters-8)\n    - [(const)iterator overlap\\_find(interval\\_type const\\\u0026 ival, bool exclusive)](#constiterator-overlap_findinterval_type-const-ival-bool-exclusive)\n      - [Parameters](#parameters-9)\n    - [(const)iterator overlap\\_find\\_all(interval\\_type const\\\u0026 ival, OnFindFunctionT const\\\u0026 on\\_find, bool exclusive)](#constiterator-overlap_find_allinterval_type-const-ival-onfindfunctiont-const-on_find-bool-exclusive)\n      - [Parameters](#parameters-10)\n      - [Example](#example-2)\n    - [(const)iterator overlap\\_find\\_next\\_in\\_subtree(interval\\_type const\\\u0026 ival, bool exclusive)](#constiterator-overlap_find_next_in_subtreeinterval_type-const-ival-bool-exclusive)\n      - [Parameters](#parameters-11)\n    - [interval\\_tree\\\u0026 deoverlap()](#interval_tree-deoverlap)\n    - [After deoverlap](#after-deoverlap)\n    - [interval\\_tree deoverlap\\_copy()](#interval_tree-deoverlap_copy)\n    - [interval\\_tree punch(interval\\_type const\\\u0026 ival)](#interval_tree-punchinterval_type-const-ival)\n    - [Before punching (closed intervals)](#before-punching-closed-intervals)\n    - [After punching (with \\[-10, 60\\])](#after-punching-with--10-60)\n    - [interval\\_tree punch()](#interval_tree-punch)\n    - [bool empty() const noexcept](#bool-empty-const-noexcept)\n    - [iterator begin()](#iterator-begin)\n    - [iterator end()](#iterator-end)\n    - [iterator cbegin()](#iterator-cbegin)\n    - [iterator cend()](#iterator-cend)\n    - [reverse\\_iterator rbegin()](#reverse_iterator-rbegin)\n    - [reverse\\_iterator rend()](#reverse_iterator-rend)\n    - [reverse\\_iterator crbegin()](#reverse_iterator-crbegin)\n    - [reverse\\_iterator crend()](#reverse_iterator-crend)\n    - [void erase\\_range(interval\\_type const\\\u0026 ival)](#void-erase_rangeinterval_type-const-ival)\n    - [void erase\\_range(interval\\_type const\\\u0026 ival, bool retainSlices)](#void-erase_rangeinterval_type-const-ival-bool-retainslices)\n  - [Members of Interval](#members-of-interval)\n    - [using value\\_type](#using-value_type)\n    - [using interval\\_kind](#using-interval_kind)\n    - [friend bool operator==(interval const\\\u0026 lhs, interval const\\\u0026 other)](#friend-bool-operatorinterval-const-lhs-interval-const-other)\n    - [friend bool operator!=(interval const\\\u0026 lhs, interval const\\\u0026 other)](#friend-bool-operatorinterval-const-lhs-interval-const-other-1)\n    - [value\\_type low() const](#value_type-low-const)\n    - [value\\_type high() const](#value_type-high-const)\n    - [DEPRECATED bool overlaps(value\\_type l, value\\_type h) const](#deprecated-bool-overlapsvalue_type-l-value_type-h-const)\n    - [bool overlaps\\_exclusive(value\\_type l, value\\_type h) const](#bool-overlaps_exclusivevalue_type-l-value_type-h-const)\n    - [bool overlaps(interval const\\\u0026 other) const](#bool-overlapsinterval-const-other-const)\n    - [bool overlaps\\_exclusive(interval const\\\u0026 other) const](#bool-overlaps_exclusiveinterval-const-other-const)\n    - [bool within(value\\_type value) const](#bool-withinvalue_type-value-const)\n    - [bool within(interval const\\\u0026 other) const](#bool-withininterval-const-other-const)\n    - [value\\_type operator-(interval const\\\u0026 other) const](#value_type-operator-interval-const-other-const)\n    - [value\\_type size() const](#value_type-size-const)\n    - [interval join(interval const\\\u0026 other) const](#interval-joininterval-const-other-const)\n    - [slice\\_type slice(interval const\\\u0026 other) const](#slice_type-sliceinterval-const-other-const)\n\n### iterator insert(interval_type const\u0026 ival)\nAdds an interval into the tree.\n#### Parameters\n* `ival` An interval\n\n**Returns**: An iterator to the inserted element.\n\n---\n### iterator insert_overlap(interval_type const\u0026 ival, bool, bool)\nInserts an interval into the tree if no other interval overlaps it.\nOtherwise merge the interval with the one being overlapped.\n#### Parameters\n* `ival` An interval\n* `exclusive` Exclude borders from overlap check. Defaults to false.\n* `recursive` If the result of interval::join is a collection of intervals, shall each be inserted with more overlap searches? If the result is a single interval, shall it be inserted via insert_overlap or insert? Defaults to false. recursive=true picks insert_overlap. Also be careful to not produce overlapping merge sets when doing recursive insertion, or it will recurse endlessly.\n\n**Returns**: An iterator to the inserted element.\n\n---\n### iterator erase(iterator iter)\nRemoves the interval given by iterator from the tree.\n(does not invalidate iterators).\n#### Parameters\n* `iter` A valid non-end iterator\n\n**Returns**: An iterator to the next element.\n\n---\n### size_type size() const\nReturns the amount of nodes in the tree.\n\n**Returns**: The amount of tree nodes.\n\n---\n### (const)iterator find(interval_type const\u0026 ival)\nFinds the first interval in the interval tree that has an exact match.\n**WARNING**: There is no special handling for floats.\n#### Parameters\n* `ival` The interval to find.\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator find(interval_type const\u0026 ival, CompareFunctionT const\u0026 compare)\nFinds the first interval in the interval tree that has the following statement evaluate to true: compare(interval_in_tree, ival);\nAllows for propper float comparisons.\n#### Parameters\n* `ival` The interval to find.\n* `compare` The compare function to compare intervals with. Function is called like so: compare(interval_in_tree, ival).\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator find_all(interval_type const\u0026 ival, OnFindFunctionT const\u0026 on_find)\nFind all intervals in the tree matching ival.\n#### Parameters\n* `ival` The interval to find.\n* `on_find` A function of type bool(iterator) that is called when an interval was found.\nReturn true to continue, false to preemptively abort search.\n#### Example\n```c++\ntree.insert({3, 7});\ntree.insert({3, 7});\ntree.insert({8, 9});\ntree.find_all({3, 7}, [](auto iter) /* iter will be const_iterator if tree is const */ {\n  // will find all intervals that are exactly {3,7} here.\n  return true; // continue\n});\n```\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator find_all(interval_type const\u0026 ival, OnFindFunctionT const\u0026 on_find, CompareFunctionT const\u0026 compare)\nFind all intervals in the tree that the compare function returns true for.\n#### Parameters\n* `ival` The interval to find.\n* `compare` The compare function to compare intervals with. Function is called like so: compare(interval_in_tree, ival).\n* `on_find` A function of type bool(iterator) that is called when an interval was found.\nReturn true to continue, false to preemptively abort search.\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator find_next_in_subtree(iterator from, interval_type const\u0026 ival)\nFinds the next exact match EXCLUDING from in the subtree originating from \"from\".\nYou cannot find all matches this way, use find_all for that.\n#### Parameters\n* `from` The iterator to start from. (including this iterator!)\n* `ival` The interval to find.\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator find_next_in_subtree(iterator from, interval_type const\u0026 ival, CompareFunctionT const\u0026 compare)\nFinds the next exact match EXCLUDING from in the subtree originating from \"from\".\nYou cannot find all matches this way, use find_all for that.\n#### Parameters\n* `from` The iterator to start from (including this iterator!)\n* `ival` The interval to find.\n* `compare` The compare function to compare intervals with. Function is called like so: compare(interval_in_tree, ival).\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator overlap_find(interval_type const\u0026 ival, bool exclusive)\nFinds the first interval in the interval tree that overlaps the given interval.\n#### Parameters\n* `ival` The interval to find an overlap for.\n* `exclusive` Exclude borders from overlap check. Defaults to false.\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator overlap_find_all(interval_type const\u0026 ival, OnFindFunctionT const\u0026 on_find, bool exclusive)\nFinds all intervals in the interval tree that overlaps the given interval.\n#### Parameters\n* `ival` The interval to find an overlap for.\n* `on_find` A function of type bool(iterator) that is called when an interval was found.\nReturn true to continue, false to preemptively abort search.\n* `exclusive` Exclude borders from overlap check. Defaults to false.\n#### Example\n```c++\ntree.insert({0, 5});\ntree.insert({5, 10});\ntree.insert({10, 15});\ntree.overlap_find_all({5, 5}, [](auto iter) /* iter will be const_iterator if tree is const */ {\n  // called with {0, 5} and {5, 10} in unspecified order.\n  return true; // continue\n});\n```\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### (const)iterator overlap_find_next_in_subtree(interval_type const\u0026 ival, bool exclusive)\nFinds the next interval in the subtree originating in ival that overlaps the given interval.\nYou cannot find all matches this way, use overlap_find_all for that.\n#### Parameters\n* `ival` The interval to find an overlap for.\n* `exclusive` Exclude borders from overlap check. Defaults to false.\n\n**Returns**: An iterator to the found element, or std::end(tree).\n\n---\n### interval_tree\u0026 deoverlap()\nMerges all overlapping intervals within the tree. After calling deoverlap, the tree will only contain disjoint intervals.\n\n**Returns**: *this\n### After deoverlap\n![AfterDeoverlap](https://user-images.githubusercontent.com/6238896/55505612-c5a96c80-5653-11e9-81f8-28a8ae35a077.png)\n\n### interval_tree deoverlap_copy()\nSame as deoverlap, but not inplace\n\n---\n### interval_tree punch(interval_type const\u0026 ival)\nCuts the intervals of the tree out of the given interval. Like a cookie cutter cuts out of dough.\nThis will return a new interval_tree containing the gaps between the intervals in the tree and the given interval.\nClosed adjacent intervals are treated as exclusive on the borders. [0,5]a[6,10]a will not produce another interval between 5 and 6 as they are considered within the intervals and nothing fits inbetween.\nRegular closed intervals will not behave like this, so [0,5][6,10] will produce a new interval [5,6].\nOpen intervals with integral numbers will also not produce the gap (5, 6), because (5, 6) is empty for integers, not for floats.\n\n**IMPORTANT! The tree must be deoverlapped, or the result is undefined.**\n`ival` can be any subrange of the tree, including encompassing the whole tree.\n\n**Returns**: A new interval_tree containing the gaps.\n### Before punching (closed intervals)\n![BeforePunch](https://5cript.github.io/readme-images/interval-tree/punch_source.png)\n### After punching (with [-10, 60])\n![AfterPunch](https://5cript.github.io/readme-images/interval-tree/punch_result.png)\n\n---\n### interval_tree punch()\nSame as punch(interval_type const\u0026 ival), but with ival = [lowest_lower_bound, highest_upper_bound], resulting in only\nthe gaps between existing intervals.\n\n---\n### bool empty() const noexcept\nReturns whether or not the tree is empty.\n\n**Returns**: Is this tree empty?\n\n---\n### iterator begin()\nReturns the iterator of the interval with the lowest lower_bound.\n\n**Returns**: begin iterator.\n\n---\n### iterator end()\nReturns a past the end iterator.\n\n**Returns**: past the end iterator.\n\n---\n### iterator cbegin()\nReturns the const_iterator of the interval with the lowest lower_bound.\n\n**Returns**: begin iterator.\n\n---\n### iterator cend()\nReturns a past the end const_iterator.\n\n**Returns**: past the end const_iterator.\n\n---\n\n### reverse_iterator rbegin()\nReturns the iterator of the interval with the highest lower_bound.\n\n**Returns**: rbegin iterator.\n\n---\n### reverse_iterator rend()\nReturns a past the end iterator in reverse.\n\n**Returns**: past the end iterator.\n\n---\n### reverse_iterator crbegin()\nReturns the const_iterator of the interval with the highest lower_bound.\n\n**Returns**: begin iterator.\n\n---\n### reverse_iterator crend()\nReturns a past the end const_iterator in reverse.\n\n**Returns**: past the end const_iterator.\n\n### void erase_range(interval_type const\u0026 ival)\nRemoves all intervals overlapping ival from the tree\n\n### void erase_range(interval_type const\u0026 ival, bool retainSlices)\nRemoves all intervals overlapping ival from the tree, but retains the overlap beyond the erase interval.\n\n## Members of Interval\n___You can implement your own interval if you provide the same functions, except (slice, operator-, size, operator!=).___\n\nThere are 6 types of intervals:\n- open: (a, b)\n- left_open: (a, b]\n- right_open: [a, b)\n- closed: [a, b]\n- closed_adjacent: [a, b] (counts adjacent intervals as overlapping)\n- dynamic: Can be any of the above, depending on the input. Not supported for floating point.\n\nWhich can be picked with the second template parameter of interval:\n`lib_interval_tree::interval\u003cint, lib_interval_tree::open\u003e`\n\n  - [Members of Interval](#members-of-interval)\n    - [using value_type](#using-value_type)\n    - [using interval_kind](#using-interval_kind)\n    - [friend bool operator==(interval const\u0026 lhs, interval const\u0026 other)](#friend-bool-operatorinterval-const-lhs-interval-const-other)\n    - [friend bool operator!=(interval const\u0026 lhs, interval const\u0026 other)](#friend-bool-operatorinterval-const-lhs-interval-const-other-1)\n    - [value_type low() const](#value_type-low-const)\n    - [value_type high() const](#value_type-high-const)\n    - [DEPRECATED bool overlaps(value_type l, value_type h) const](#bool-overlapsvalue_type-l-value_type-h-const)\n    - [bool overlaps_exclusive(value_type l, value_type h) const](#bool-overlaps_exclusivevalue_type-l-value_type-h-const)\n    - [bool overlaps(interval const\u0026 other) const](#bool-overlapsinterval-const-other-const)\n    - [bool overlaps_exclusive(interval const\u0026 other) const](#bool-overlaps_exclusiveinterval-const-other-const)\n    - [bool within(value_type value) const](#bool-withinvalue_type-value-const)\n    - [bool within(interval const\u0026 other) const](#bool-withininterval-const-other-const)\n    - [value_type operator-(interval const\u0026 other) const](#value_type-operator-interval-const-other-const)\n    - [value_type size() const](#value_type-size-const)\n    - [interval join(interval const\u0026 other) const](#interval-joininterval-const-other-const)\n    - [slice\\_type slice(interval const\\\u0026 other) const](#slice_type-sliceinterval-const-other-const)\n\n### using value_type\nThe underlying interval numerical type\n### using interval_kind\nThe interval kind. You dont need to provides this typedef in your interval class.\n### friend bool operator==(interval const\u0026 lhs, interval const\u0026 other)\nComparison operator.\n### friend bool operator!=(interval const\u0026 lhs, interval const\u0026 other)\nComparison operator.\n### value_type low() const\nLower bound.\n### value_type high() const\nUpper bound.\n### DEPRECATED bool overlaps(value_type l, value_type h) const\nOverlap these bounds with this interval?\nIs deprecated because the overlapping does not work with the dynamic interval type.\n### bool overlaps_exclusive(value_type l, value_type h) const\nOverlap these bounds with this interval excluding borders?\n### bool overlaps(interval const\u0026 other) const\nLike overlaps with lower and upper bound.\n### bool overlaps_exclusive(interval const\u0026 other) const\nLike overlaps with lower and upper bound.\n### bool within(value_type value) const\nIs the value within the interval?\n### bool within(interval const\u0026 other) const\nIs the interval within the interval?\n### value_type operator-(interval const\u0026 other) const\nCalculates the distance between the two intervals.\nOverlapping intervals have 0 distance.\n### value_type size() const\nReturns The amount of elements in the interval when integral, or the distance between the 2 bounds when floating point.\n### interval join(interval const\u0026 other) const\nJoins 2 intervals and whatever is inbetween.\n### slice_type slice(interval const\u0026 other) const\nRemoves other from this interval returning what is remaining.\nThe range of other going beyond the range of this is ignored.\nReturns a struct with 2 members: left_slice and right_slice.\n```\n[   this interval  ]\n[left][other][right]\n```\n\nWhen the intervals are closed_adjacent, adjacent results are differenty by 1.\n[0, 9].slice([5, 19]) =\u003e left: [0, 4], right: nullopt","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5cript%2Finterval-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F5cript%2Finterval-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5cript%2Finterval-tree/lists"}