diff --git a/README.md b/README.md index de17c291..b3aa314c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ A growing library of assorted data structures, algorithms and utilities. - [`orx-file-watcher`](orx-file-watcher/README.md), `Program` extension method that allows monitoring and hot loading from files. - [`orx-filter-extension`](orx-filter-extension/README.md), `Program` extension method that provides Filter based `extend()` - [`orx-integral-image`](orx-integral-image/README.md), CPU-based and GPU-based implementation for integral images (summed area tables) +- [`orx-interval-tree`](orx-interval-tree/README.md), datastructure for accelerating point-in-interval queries. - `orx-jumpflood`, a filter/shader based implementation of the jump flood algorithm for finding fast approximate (directional) distance fields - `orx-kdtree`, a kd-tree implementation for fast nearest point searches - [`orx-mesh-generators`](orx-mesh-generators/README.md), triangular mesh generators diff --git a/orx-interval-tree/README.md b/orx-interval-tree/README.md new file mode 100644 index 00000000..fb1c2007 --- /dev/null +++ b/orx-interval-tree/README.md @@ -0,0 +1,24 @@ +# orx-interval-tree + +Interval trees intend to speed-up point in interval queries. Specifically in cases with a large set of items with a given +fixed start and end time. + +For more information on interval trees read the [wikipedia page](https://en.wikipedia.org/wiki/Interval_tree). + +## Usage +``` +// -- the item class we want to search for +class Item(val start: Double, val end: Double) + +// -- the items we want to search in +val items = List(100000) { Item(Math.random(), 1.0 + Math.random()) } + +// -- build the interval tree, note how buildIntervalTree accepts a function that returns the start and end of the interval. +val tree = buildIntervalTree(items) { + Pair(it.start, it.end) +} + +// -- search for all items that intersect 0.05 +val results = tree.queryPoint(0.05) +``` +