public void insert ( NumberVector nv ) { final int dim = nv . getDimensionality ( ) ; // No root created yet: if ( root == null ) { ClusteringFeature leaf = new ClusteringFeature ( dim ) ; leaf . addToStatistics ( nv ) ; root = new TreeNode ( dim , capacity ) ; root . children [ 0 ] = leaf ; root . addToStatistics ( nv ) ; ++ leaves ; return ; } TreeNode other = insert ( root , nv ) ; // Handle root overflow: if ( other != null ) { TreeNode newnode = new TreeNode ( dim , capacity ) ; newnode . addToStatistics ( newnode . children [ 0 ] = root ) ; newnode . addToStatistics ( newnode . children [ 1 ] = other ) ; root = newnode ; } }
Insert a data point into the tree .