|
|
@ -30,20 +30,23 @@ |
|
|
|
initTree: function (nodes) { |
|
|
|
initTree: function (nodes) { |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
this.clear(); |
|
|
|
this.clear(); |
|
|
|
var queue = []; |
|
|
|
var queue = new Set(); |
|
|
|
|
|
|
|
|
|
|
|
BI.each(nodes, function (i, node) { |
|
|
|
BI.each(nodes, function (i, node) { |
|
|
|
var n = new BI.Node(node); |
|
|
|
var n = new BI.Node(node); |
|
|
|
n.set("data", node); |
|
|
|
n.set("data", node); |
|
|
|
self.addNode(n); |
|
|
|
self.addNode(n); |
|
|
|
queue.push(n); |
|
|
|
queue.add(n); |
|
|
|
}); |
|
|
|
}); |
|
|
|
while (!BI.isEmpty(queue)) { |
|
|
|
while (queue.size > 0) { |
|
|
|
var parent = queue.shift(); |
|
|
|
var [parent] = queue; |
|
|
|
|
|
|
|
queue.delete(parent); |
|
|
|
|
|
|
|
|
|
|
|
var node = parent.get("data"); |
|
|
|
var node = parent.get("data"); |
|
|
|
BI.each(node.children, function (i, child) { |
|
|
|
BI.each(node.children, function (i, child) { |
|
|
|
var n = new BI.Node(child); |
|
|
|
var n = new BI.Node(child); |
|
|
|
n.set("data", child); |
|
|
|
n.set("data", child); |
|
|
|
queue.push(n); |
|
|
|
queue.add(n); |
|
|
|
self.addNode(parent, n); |
|
|
|
self.addNode(parent, n); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|