# @yiminghe/rbtree

> red-black-tree

Latest version **0.2.4** (published 2020-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @yiminghe/rbtree
pnpm add @yiminghe/rbtree
yarn add @yiminghe/rbtree
bun add @yiminghe/rbtree
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2020-03-25 |
| First published | 2020-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 89.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | yiminghe |

## Links

- npm: https://www.npmjs.com/package/@yiminghe/rbtree
- Repository: https://github.com/yiminghe/rbtree
- Homepage: http://github.com/yiminghe/rbtree
- Issues: http://github.com/yiminghe/rbtree/issues
- npm.io page: https://npm.io/package/@yiminghe/rbtree

## Recent versions

- 0.2.4 (latest) — 2020-03-25
- 0.2.2 — 2020-01-30
- 0.2.1 — 2020-01-30
- 0.1.5 — 2020-01-17
- 0.1.4 — 2020-01-17
- 0.1.3 — 2020-01-17
- 0.1.1 — 2020-01-17
- 0.1.0 — 2020-01-17

## README

# @yiminghe/rbtree
---

red-black tree

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]

[npm-image]: http://img.shields.io/npm/v/@yiminghe/rbtree.svg?style=flat-square
[npm-url]: http://npmjs.org/package/@yiminghe/rbtree
[travis-image]: https://img.shields.io/travis/yiminghe/rbtree.svg?style=flat-square
[travis-url]: https://travis-ci.org/yiminghe/rbtree
[coveralls-image]: https://img.shields.io/coveralls/yiminghe/rbtree.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/yiminghe/rbtree?branch=master
[gemnasium-image]: http://img.shields.io/gemnasium/yiminghe/rbtree.svg?style=flat-square
[gemnasium-url]: https://gemnasium.com/yiminghe/rbtree
[node-image]: https://img.shields.io/badge/node.js-%3E=10.0.0-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/@yiminghe/rbtree.svg?style=flat-square
[download-url]: https://npmjs.org/package/@yiminghe/rbtree

## usage

```
import RBTree from '@yiminghe/rbtree';
const tree = new RBTree();

tree.insert(10,'a');
tree.insert(11,'b');
tree.delete(10);

console.log(tree.find(10)) // => undefined
console.log(tree.find(11)) // => 'b'
```

## API

### class RBTree

### methods

### constructor(sorter:(aKey, bKey)=>number, merger:(aVal,bVal)=>any)

sort function: aKey>bKey:>0, aKey==bKey:0, aKey<bKey:<0, sorter defaults to: (a,b)=>a-b;

merger function: how to merge val when key is the same, defaults to override with new val

#### insert(key:any,value:any)

#### delete(key:any)

#### has(key:any):boolean

check whether tree has key node

#### find(key:any)

find value associated with this key

#### lowerBound(key:any)

find val by lower bound

#### upperBound(key:any)

find val by upper bound

---
_Source: https://npm.io/package/@yiminghe/rbtree · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
