Skip to content

Commit 7848f18

Browse files
committed
Added examples.
1 parent 8c49d18 commit 7848f18

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ Find all intervals in the tree matching ival.
105105
* `ival` The interval to find.
106106
* `on_find` A function of type bool(iterator) that is called when an interval was found.
107107
Return true to continue, false to preemptively abort search.
108+
#### Example
109+
```c++
110+
tree.insert({3, 7});
111+
tree.insert({3, 7});
112+
tree.insert({8, 9});
113+
tree.find_all({3, 7}, [](auto iter) /* iter will be const_iterator if tree is const */ {
114+
// will find all intervals that are exactly {3,7} here.
115+
});
116+
```
108117

109118
**Returns**: An iterator to the found element, or std::end(tree).
110119

@@ -157,6 +166,15 @@ Finds the first interval in the interval tree that overlaps the given interval.
157166
* `on_find` A function of type bool(iterator) that is called when an interval was found.
158167
Return true to continue, false to preemptively abort search.
159168
* `exclusive` Exclude borders from overlap check. Defaults to false.
169+
#### Example
170+
```c++
171+
tree.insert({0, 5});
172+
tree.insert({5, 10});
173+
tree.insert({10, 15});
174+
tree.overlap_find_all({5, 5}, [](auto iter) /* iter will be const_iterator if tree is const */ {
175+
// called with {0, 5} and {5, 10} in unspecified order.
176+
});
177+
```
160178

161179
**Returns**: An iterator to the found element, or std::end(tree).
162180

0 commit comments

Comments
 (0)