花了一周时间才想明白,稍后补上删除代码
package tree;
import java.lang.reflect.Array;
@SuppressWarnings("unchecked")
public class ProtoVEBTree {
public Node root;
public ProtoVEBTree(int length) {
this.root = new Node(length);
}
public static class Node {
protected int u;
protected Object[] nodeArray;
protected Node summary;
/*
Node的构造方法顺带初始化protoVEBTree
*/
protected Node(int u) {
this.u = u;
if (u == 2) {
this.summary = null;
this.nodeArray = new Object[2];
this.nodeArray[0] = this.nodeArray[1] = 0;
} else {
int childSize = (int) (Math.sqrt(u));
this.nodeArray = (Object[]) (Array.newInstance(Node.class, childSize));
for (int i = 0; i < this.nodeArray.length; i++)