Socket
Book a DemoInstallSign in
Socket

@protontech/interval-tree

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@protontech/interval-tree

Red-black interval tree

1.0.0
latest
npmnpm
Version published
Weekly downloads
7.2K
0.97%
Maintainers
3
Weekly downloads
 
Created
Source

Interval tree

Augemented red-black tree with support for operations on dynamic sets of intervals

Based on interval tree described in Introduction to Algorithms Third Edition, published by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein.

API

import

Creates an interval tree

import createIntervalTree from 'interval-tree';

const tree = createIntervalTree();

insert(low, high, id)

Inserts an interval into the tree

tree.insert(10, 15, '123');

remove(low, high, id)

Removes an interval from the tree

tree.remove(10, 15, '123');

search(low, high)

Searches overlapping intervals in an inclusive range

const results = tree.search(10, 15);

Where results is an array of matching intervals, where each item is an array of 3 items:

[low, high, id]

FAQs

Package last updated on 01 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.