在下面的代码中,有 2 个类,一个是 Node,另一个是 Btree。如果在节点上调用 split() 实例,那么我想创建新节点,将其保存为父节点,然后更改 Btree 的根节点。
Node如何访问Btree.root?我必须使用类继承吗?(这段代码不是完整的代码,所以可能会有一些错误......虽然我只是想了解一下)
Node = function(dimension,root){
this.root = root;
this.parent = null;
}
Node.prototype.split = function(
var tmp = new Node();
if(!this.parent){
var soon_to_be_root = new Node();
this.parent = soon_to_be_root;
}
}
Btree = function(dimension){
this.d = dimension;
this.root = new Node(dimension,true);
}