{"author":{"name":"Vadim Graboys","email":"dimva13@gmail.com"},"name":"bintrees","description":"Binary Search Trees","version":"0.0.1","homepage":"bitfloor.com","repository":{"type":"git","url":"git://github.com/vadimg/js_bintrees.git"},"directories":{"lib":"lib"},"main":"./lib/index.js","scripts":{"test":"expresso ./test/test_*.js"},"engines":{"node":"~v0.4.8"},"dependencies":{},"devDependencies":{"underscore":">=1.1.7","expresso":">=0.8.1"},"_npmJsonOpts":{"file":"/home/vadim/.npm/bintrees/0.0.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"bintrees@0.0.1","_engineSupported":true,"_npmVersion":"1.0.22","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"675c4259dec843f60368387d83680e1025b01159","tarball":"http://registry-npm.ywwl.com/bintrees/download/bintrees-0.0.1.tgz","integrity":"sha512-UODwl6DhajJWWNEqi03qhOoy1jB4rAItbykKpKLLB1HTwbuNN0EfRtO6I91h6JRZjd+o2eKoOSpOe8/l9WzHMA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDn5pONJgaSLXGmuj9hkGBoD1MV3v+eDpKGQfHQ2e78aAiEAxmGDcYZLWu0Ut0wPswCyi3PfEZPe4cUis5n8UNRk++A="}],"size":1083646,"noattachment":false,"key":"/bintrees/-/bintrees-0.0.1.tgz"},"maintainers":[{"name":"vadimg","email":"dimva13@gmail.com"}],"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":1312350120218,"_cnpm_publish_time":1312350120218,"dist-tags":{"latest":"1.0.2"}}