Files
orx/orx-interval-tree
Edwin Jakobs b7ba6f6daa Feature variants (#376)
Migrate from buildSrc to build-logic. Setup feature variants.
2025-09-17 10:03:02 +02:00
..
2025-09-17 10:03:02 +02:00

orx-interval-tree

For querying a data set containing time segments (start time and end time) when we need all entries containing a specific time value. Useful when creating a timeline.

For more information on interval trees read the wikipedia page.

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)