TreeMap.js
A binary tree based map (aka dictionary) data type for Javascript, keeping keys sorted at all times. Provides O(log n)
average case performance for inserting, retrieving and removing values.
Installation
Works with Node and in the browser.
Node
Install via npm install treemap-js
. Then access the TreeMap like this:
const TreeMap = require("treemap-js");
Browser
Include TreeMap.js
in your HTML. TreeMap
is automatically appended to the window
object.
Usage
var map = new TreeMap();
map.set("my first key", "hello");
map.set("second key", [ 1, 3, 4 ]);
map.get("my first key");
map.set("my first key", 2342);
map.get("my first key");
map.getLength();
map.getMinKey();
map.getMaxKey();
map.each(function (value, key) {
});
map.remove("my first key");
map.getLength();
map.getTree();