diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-04-16 15:08:44 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-04-16 15:08:44 -0400 |
| commit | 3412cc42a9fa5e42d47073a2fa05a39712ad40f7 (patch) | |
| tree | 016356ab239e51b1948ee2e2252bc847e13b17ba /assets/javascripts/rectangles/tree.js | |
| parent | e50348e6d5af52d0fcc51d0ca30e21594aee6cbf (diff) | |
layer of indirection for rooms
Diffstat (limited to 'assets/javascripts/rectangles/tree.js')
| -rw-r--r-- | assets/javascripts/rectangles/tree.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/assets/javascripts/rectangles/tree.js b/assets/javascripts/rectangles/tree.js index f5eb117..577c41a 100644 --- a/assets/javascripts/rectangles/tree.js +++ b/assets/javascripts/rectangles/tree.js @@ -15,6 +15,13 @@ tree.prototype.add = function(n, data){ if (n < closest.value) return closest.lo = new tree(n, data) if (n > closest.value) return closest.hi = new tree(n, data) } +tree.prototype.toArray = function(){ + var a = [] + if (this.lo) a = a.concat(this.lo.toArray()) + a.push(this.data) + if (this.hi) a = a.concat(this.hi.toArray()) + return a +} tree.prototype.toString = function(){ var s = ""; if (this.lo) s += this.lo.toString() |
