{"author":{"name":"Vadim Graboys","email":"dimva13@gmail.com"},"name":"bintrees","description":"Binary Search Trees","version":"1.0.1","keywords":["binary tree","red black tree","red-black tree","redblack tree"],"repository":{"type":"git","url":"git://github.com/vadimg/js_bintrees.git"},"directories":{"lib":"lib"},"main":"./index.js","scripts":{"test":"nodeunit ./test/test_*.js && jshint lib/*.js index.js"},"dependencies":{},"devDependencies":{"nodeunit":"0.9.1","jshint":"0.5.9","underscore":"1.3.1","reunion":"0.0.0"},"gitHead":"cfae7fcb27ea2550f9c6aeb81cebef6a37f7783e","bugs":{"url":"https://github.com/vadimg/js_bintrees/issues"},"homepage":"https://github.com/vadimg/js_bintrees","_id":"bintrees@1.0.1","_shasum":"0e655c9b9c2435eaab68bf4027226d2b55a34524","_from":".","_npmVersion":"2.7.3","_nodeVersion":"0.12.1","_npmUser":{"name":"vadimg","email":"dimva13@gmail.com"},"maintainers":[{"name":"vadimg","email":"dimva13@gmail.com"}],"dist":{"shasum":"0e655c9b9c2435eaab68bf4027226d2b55a34524","tarball":"http://registry-npm.ywwl.com/bintrees/download/bintrees-1.0.1.tgz","integrity":"sha512-tbaUB1QpTIj4cKY8c1rvNAvEQXA+ekzHmbe4jzNfW3QWsF9GnnP/BRWyl6/qqS53heoYJ93naaFcm/jooONH8g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEioF9HI3hly1VBG5hTzguCm0uNahrhcj9QN+b5NzRP+AiAzYqAAhsB2/KNZ7KLix8tsS00YBMYekE3Ly15wFJuBJQ=="}],"size":1088854,"noattachment":false,"key":"/bintrees/-/bintrees-1.0.1.tgz"},"readme":"Binary Trees [![Build Status](https://secure.travis-ci.org/vadimg/js_bintrees.png?branch=master)](http://travis-ci.org/vadimg/js_bintrees)\n============\n\nThis package provides Binary and Red-Black Search Trees written in Javascript. It is released under the MIT License.\n\nBinary Search Trees are a good way to store data in sorted order. A Red-Black tree is a variation of a Binary Tree that balances itself.\n\nAlgorithms were taken from Julienne Walker: http://eternallyconfuzzled.com/jsw_home.aspx\n\nTrees\n------------\n\n* BinTree - Binary Search Tree\n* RBTree - Red-Black Tree\n\nQuickstart\n------------\nnode.js:\n\n```\nnpm install bintrees\n```\n\n```javascript\nvar RBTree = require('bintrees').RBTree;\n\nvar tree = new RBTree(function(a, b) { return a - b; });\n\ntree.insert(2);\ntree.insert(-3);\n```\n\nsee examples/node.js for more info\n\nIn the browser:\n\n```html\n<script src=\"/path/to/rbtree.js\"></script>\n<script>\n    var tree = new RBTree(function(a, b) { return a - b; });\n    tree.insert(0);\n    tree.insert(1);\n</script>\n```\n\nsee examples/client.html for more info\n\nConstructor\n------------\n\nRequires 1 argument: a comparator function f(a,b) which returns:\n* 0 if a == b\n* >0 if a > b\n* <0 if a < b\n\nMethods\n------------\n\n### insert(item)\n> Inserts the item into the tree. Returns true if inserted, false if duplicate.\n\n### remove(item)\n> Removes the item from the tree. Returns true if removed, false if not found.\n\n### size\n> Number of nodes in the tree.\n\n### clear()\n> Removes all nodes from the tree.\n\n### find(item)\n> Returns node data if found, null otherwise.\n\n### findIter(item)\n> Returns an iterator to the node if found, null otherwise.\n\n### lowerBound(item)\n> Returns an iterator to the tree node at or immediately after the item. Returns null-iterator if tree is empty.\n>> __NOTE: Changed in version 1.0.0 to match C++ lower_bound__\n\n### upperBound(item)\n> Returns an iterator to the tree node immediately after the item. Returns null-iterator if tree is empty.\n>> __NOTE: Changed in version 1.0.0 to match C++ upper_bound__\n\n### min()\n> Returns the min node data in the tree, or null if the tree is empty.\n\n### max()\n> Returns the max node data in the tree, or null if the tree is empty.\n\n### each(f)\n> Calls f on each node's data, in order.\n\n### reach(f)\n> Calls f on each node's data, in reverse order.\n\n### iterator()\n> Returns a null-iterator. See __Iterators__ section below.\n\nIterators\n------------\n\ntree.iterator() will return a null-iterator. On a null iterator,\n* next() will return the first element in the tree\n* prev() will return the last element in the tree\n\nOtherwise,\n* next() will return the next element\n* prev() will return the previous element\n* data() will return the node the iterator is pointing to\n\nWhen iteration reaches the end, the iterator becomes a null-iterator again.\n\nForward iteration example:\n\n```javascript\nvar it=tree.iterator(), item;\nwhile((item = it.next()) !== null) {\n    // do stuff with item\n}\n```\n\nIf you are iterating forward through the tree, you can always call prev() to go back, and vice versa.\n\n__NOTE:__ iterators become invalid when you add or remove elements from the tree.\n\n## Production Usage\n\n* [Coinbase Exchange](https://exchange.coinbase.com/), since Jan 26, 2015.\n* If you are using this in production, please let me know! (add your company to this README in a pull request)\n","publish_time":1437731418982,"_cnpm_publish_time":1437731418982,"dist-tags":{"latest":"1.0.2"}}