summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/tree.js
diff options
context:
space:
mode:
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()