summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/tree.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-04-16 15:08:44 -0400
committerJules Laplace <jules@okfoc.us>2014-04-16 15:08:44 -0400
commit3412cc42a9fa5e42d47073a2fa05a39712ad40f7 (patch)
tree016356ab239e51b1948ee2e2252bc847e13b17ba /assets/javascripts/rectangles/tree.js
parente50348e6d5af52d0fcc51d0ca30e21594aee6cbf (diff)
layer of indirection for rooms
Diffstat (limited to 'assets/javascripts/rectangles/tree.js')
-rw-r--r--assets/javascripts/rectangles/tree.js7
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()