# interval-tree-1d

> 1D interval tree data structure

Latest version **1.0.4** (published 2021-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install interval-tree-1d
pnpm add interval-tree-1d
yarn add interval-tree-1d
bun add interval-tree-1d
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-06-03 |
| First published | 2013-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 72 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | point, location, interval, range, query, search, overlap |

## Links

- npm: https://www.npmjs.com/package/interval-tree-1d
- Repository: https://github.com/mikolalysenko/interval-tree-1d
- Homepage: https://github.com/mikolalysenko/interval-tree-1d#readme
- Issues: https://github.com/mikolalysenko/interval-tree-1d/issues
- npm.io page: https://npm.io/package/interval-tree-1d

## Dependencies (1)

- [binary-search-bounds](https://npm.io/package/binary-search-bounds.md) ^2.0.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2021-06-03
- 1.0.3 — 2015-03-29
- 1.0.2 — 2015-03-28
- 1.0.1 — 2014-11-17
- 1.0.0 — 2014-04-29
- 0.0.1 — 2014-01-28
- 0.0.0 — 2013-10-16

## README

interval-tree-1d
================
A simple 1D interval tree.  Supports O(log(n)) amortized updates and O(log(n)) queries.

[![build status](https://secure.travis-ci.org/mikolalysenko/interval-tree-1d.png)](http://travis-ci.org/mikolalysenko/interval-tree-1d)

# Example

```javascript
var createIntervalTree = require("interval-tree-1d")

//Create some random list of intervals
var intervals = [ [1, 2], [-1, 0], [0.5, 1], [-10, 10] ]

//Build tree
var tree = createIntervalTree(intervals)

//Find all intervals containing query point 0.7
console.log("querying point:", 0.7)
tree.queryPoint(0.7, function(interval) {
  console.log(interval)
})
```

# API

```javascript
var createIntervalTree = require("interval-tree-1d")
```

## Constructor

### `var tree = createIntervalTree(intervals)`
Constructs an interval tree given a list of intervals

## Properties

### `tree.count`
Returns the number of items in the tree

### `tree.intervals`
Returns a list of all the intervals in the tree

### `tree.insert(interval)`
Adds an interval to the tree

### `tree.remove(interval)`
Removes an interval from the tree

### `tree.queryPoint(p, visit(interval))`
Visits all intervals containing the point p

### `tree.queryInterval(lo, hi, visit(interval))`
Returns all intervals which intersect the interval `[lo, hi]`

# Credits
(c) 2013-2015 Mikola Lysenko. MIT License

---
_Source: https://npm.io/package/interval-tree-1d · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
