Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

segment-tree

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

segment-tree

Segment tree data structure

Source
npmnpm
Version
0.0.0
Version published
Weekly downloads
15
87.5%
Maintainers
1
Weekly downloads
 
Created
Source

segment-tree

A minimal implementation of a segment tree for storing run-length encoded arrays with updates.

Example

var tree = require("segment-tree").zeros(10)

tree.set(1, 1)
tree.set(2, 1)

console.log(tree.pointers)
console.log(tree.values)

Install

npm install segment-tree

API

var SegmentTree = require("segment-tree")

SegmentTree(size, pointers, values)

SegmentTree constructor

  • size is the size of the segment tree
  • pointers is a sorted list of pointers
  • values is a sorted list of values

SegmentTree.proto.get(index)

Retrieves the value index

  • index is the coordinate of the value to retrieve

Returns The value at index

SegmentTree.proto.set(index, v)

Sets the value at index to v

  • index is the index to update
  • v is the new value

Returns v

SegmentTree.zeros(size)

Create an empty segment tree

  • size is the size of the new segment tree

Returns A new segment tree

Credits

(c) 2013 Mikola Lysenko. MIT License

Keywords

rle

FAQs

Package last updated on 11 Jun 2013

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