Skip to content

golozubov/ranges

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Range Collection

A pair of integers define a range, for example: [1, 5). This range includes integers: 1, 2, 3, and 4.

A range collection is an aggregate of these ranges: [1, 5), [10, 11), [100, 201).

RangeCollection class is a simple implementation of ranges storage.

It's based on binary tree, where leaves store original ranges.

Usage

const rc = new RangeCollection();

rc.add([1, 5]);

rc.print();  // => '[1; 5)'

rc.remove([3, 4]);

rc.print();  // => '[1; 3) [4; 5)'

Installation

You need Node.js v10.15.1 to run this. So the simplest way to install it is to use nvm. Run the next commands:

$ nvm use
$ npm ci

Testing

$ npm test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published