diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-04-15 16:08:40 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-04-15 16:50:30 -0400 |
| commit | d6e459e2808ea16a4a0715e294182bafe74d310c (patch) | |
| tree | 7fe79c28d09917db7f06db2b5420500749a1b2f4 /tree.js | |
| parent | af825cefe94eb8a677d61bc6721451af63105988 (diff) | |
rearranging things
Diffstat (limited to 'tree.js')
| -rw-r--r-- | tree.js | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/tree.js b/tree.js deleted file mode 100644 index 07b90c6..0000000 --- a/tree.js +++ /dev/null @@ -1,24 +0,0 @@ -var tree = function(n, data){ - this.lo = null - this.hi = null - this.value = n - this.data = data -} -tree.prototype.find = function(n){ - if (n == this.value) return this - if (n < this.value) return this.lo ? this.lo.find(n) : this - if (n > this.value) return this.hi ? this.hi.find(n) : this -} -tree.prototype.add = function(n, data){ - var closest = this.find(n) - if (n == closest.value) return closest - if (n < closest.value) return closest.lo = new tree(n, data) - if (n > closest.value) return closest.hi = new tree(n, data) -} -tree.prototype.toString = function(){ - var s = ""; - if (this.lo) s += this.lo.toString() - s += this.value + "," - if (this.hi) s += this.hi.toString() - return s -} |
