Skip to content

Commit 604d921

Browse files
committed
Doc revisions
1 parent b7045b9 commit 604d921

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

README.md

+17-23
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
implementations provided by [@vadimg](https://github.com/vadimg/js_bintrees)
55
and and mixes in features of CanJS that make the data structures observable.
66

7-
Note: Currently, the only data structure in the package that is observable is
8-
the `can.RBTreeList`, which was adapted from the `can.RBTree` data structure
9-
for use in CanJS' [can-derive plugin](https://github.com/canjs/can-derive).
10-
117
> - [Install](#install)
128
> - [Use](#use)
139
> - [Data Structures](#data-structures)
@@ -49,41 +45,33 @@ npm install can-binarytree --save
4945
Use `require` in Node/Browserify workflows to import `can-binarytree` like:
5046

5147
```js
52-
var binaryTree = require('can-binarytree');
48+
var can = require('can');
49+
require('can-binarytree');
5350
```
5451

5552
Use `define`, `require` or `import` in [StealJS](http://stealjs.com)
5653
workflows to import `can-binarytree` like:
5754

5855
```js
59-
import binaryTree from 'can-binarytree'
56+
import can from 'can';
57+
import 'can-binarytree';
6058
```
6159

6260
Once you've imported `can-binarytree` into your project, use it to
6361
create observable binary tree data structures. The following example
64-
formats and `console.log`'s the current list of values as they are
65-
added to a Red-Black Tree List:
62+
`console.log`'s some metadata about each node that's added to a
63+
`can.RBTreeList`:
6664

6765
```js
6866
var tree = new can.RBTreeList();
6967

70-
tree.bind('add', function () {
71-
tree.print(function (node) {
72-
return '<' + node.data + '>';
73-
});
68+
tree.bind('add', function (ev, nodes) {
69+
console.log(node[0]);
7470
})
7571

76-
tree.push('Hop');
77-
// <Hop>
78-
79-
tree.push('Skip');
80-
// <Hop>------
81-
// -----<Skip>
82-
83-
tree.push('Jump');
84-
// -----<Skip>------
85-
// <Hop>------<Jump>
86-
72+
tree.push('Hop'); // Node {id: 0, parent: null, data: "Hop", left: null, right: null...}
73+
tree.push('Skip'); // Node {id: 2, parent: Node, data: "Skip", left: null, right: null...}
74+
tree.push('Jump'); // Node {id: 4, parent: Node, data: "Jump", left: null, right: null...}
8775
```
8876

8977

@@ -94,12 +82,18 @@ tree.push('Jump');
9482
- RBTree - A self-balancing binary tree that serves as a key-value store
9583
- BinTree - A binary tree that is not balanced
9684

85+
Note: Currently, the only data structure in the package that is observable is
86+
the `can.RBTreeList`.
87+
9788

9889
## API
9990

10091

10192
### can.RBTreeList
10293

94+
A red-black tree that uses a numeric "index" as the "key" in the same way
95+
a `can.List` or native Javascript array might, yet still performs insert and
96+
remove operations in `O(log n)` time.
10397

10498
#### .attr()
10599

0 commit comments

Comments
 (0)