@@ -22,8 +22,13 @@ int main()
2222{
2323 using namespace lib_interval_tree;
2424
25- // interval_tree <interval <int >>;
26- interval_tree_t <int > tree;
25+ // interval_tree<interval<int >>; // closed by default
26+ // interval_tree<interval<int, open>>;
27+ // interval_tree<interval<int, closed>>;
28+ // interval_tree<interval<int, left_open>>;
29+ // interval_tree<interval<int, right_open>>;
30+ // interval_tree<interval<int, closed_adjacent>>; // counts adjacent intervals as overlapping
31+ interval_tree_t<int > tree;
2732
2833 tree.insert(make_safe_interval<int >(21, 16)); // make_safe_interval swaps low and high if not in right order.
2934 tree.insert({8, 9});
@@ -42,6 +47,12 @@ int main()
4247 {
4348 std::cout << "[ " << i.low() << ", " << i.high() << "] \n";
4449 }
50+
51+ using lib_interval_tree::open;
52+ // dynamic has some logic overhead.
53+ interval_tree<interval<int, dynamic>> dynamicIntervals;
54+ dynamicIntervals.insert({0, 1, interval_border::closed, interval_border::open});
55+ dynamicIntervals.insert({7, 5, interval_border::open, interval_border::closed_adjacent});
4556}
4657```
4758
@@ -315,7 +326,18 @@ Returns a past the end const_iterator in reverse.
315326** Returns** : past the end const_iterator.
316327
317328## Members of Interval
318- ___ You can implement your own interval if you provide all the same functions.___
329+ ___ You can implement your own interval if you provide the same functions, except (within, operator-, size, operator!=).___
330+
331+ There are 6 types of intervals:
332+ - open: (a, b)
333+ - left_open: (a, b]
334+ - right_open: [ a, b)
335+ - closed: [ a, b]
336+ - closed_adjacent: [ a, b] (counts adjacent intervals as overlapping)
337+ - dynamic: Can be any of the above, depending on the input. Not supported for floating point.
338+
339+ Which can be picked with the second template parameter of interval:
340+ ` lib_interval_tree::interval<int, lib_interval_tree::open> `
319341
320342 - [ Members of Interval] ( #members-of-interval )
321343 - [ using value_type] ( #using-value_type )
@@ -324,7 +346,7 @@ ___You can implement your own interval if you provide all the same functions.___
324346 - [ friend bool operator!=(interval const& lhs, interval const& other)] ( #friend-bool-operatorinterval-const-lhs-interval-const-other-1 )
325347 - [ value_type low() const] ( #value_type-low-const )
326348 - [ value_type high() const] ( #value_type-high-const )
327- - [ bool overlaps(value_type l, value_type h) const] ( #bool-overlapsvalue_type-l-value_type-h-const )
349+ - [ \[\[ deprecated \]\] bool overlaps(value_type l, value_type h) const] ( #bool-overlapsvalue_type-l-value_type-h-const )
328350 - [ bool overlaps_exclusive(value_type l, value_type h) const] ( #bool-overlaps_exclusivevalue_type-l-value_type-h-const )
329351 - [ bool overlaps(interval const& other) const] ( #bool-overlapsinterval-const-other-const )
330352 - [ bool overlaps_exclusive(interval const& other) const] ( #bool-overlaps_exclusiveinterval-const-other-const )
@@ -346,22 +368,23 @@ Comparison operator.
346368Lower bound.
347369### value_type high() const
348370Upper bound.
349- ### bool overlaps(value_type l, value_type h) const
371+ ### \[\[ deprecated \]\] bool overlaps(value_type l, value_type h) const
350372Overlap these bounds with this interval (closed)?
373+ Is deprecated because the overlapping only works with closed intervals.
351374### bool overlaps_exclusive(value_type l, value_type h) const
352375Overlap these bounds with this interval excluding borders?
353376### bool overlaps(interval const& other) const
354377Like overlaps with lower and upper bound.
355378### bool overlaps_exclusive(interval const& other) const
356379Like overlaps with lower and upper bound.
357380### bool within(value_type value) const
358- Is the value within the interval (closed) ?
381+ Is the value within the interval?
359382### bool within(interval const& other) const
360383Is the interval within the interval?
361384### value_type operator-(interval const& other) const
362385Calculates the distance between the two intervals.
363386Overlapping intervals have 0 distance.
364387### value_type size() const
365- Returns high - low .
388+ Returns The amount of elements in the interval when integral, or the distance between the 2 bounds when floating point .
366389### interval join(interval const& other) const
367390Joins 2 intervals and whatever is inbetween.
0 commit comments