@@ -51,7 +51,6 @@ public class BTNode<T> {
51
51
this .values = values ;
52
52
}
53
53
54
- @ SuppressWarnings ("unchecked" )
55
54
BTNode (double [] center , double radius , BTNode <T > parent , BTNode <T > left , BTNode <T > right ) {
56
55
this .center = center ;
57
56
this .radius = radius ;
@@ -61,7 +60,7 @@ public class BTNode<T> {
61
60
this .right = right ;
62
61
}
63
62
64
- @ SuppressWarnings ({ "unchecked" , "unused" })
63
+ @ SuppressWarnings ({"unused" })
65
64
BTNode <T > tryPut (PointEntry <T > e , int maxNodeSize , boolean enforceLeaf ) {
66
65
if (BallTree .DEBUG && !BTUtil .fitsIntoNode (e .point (), center , radius )) {
67
66
throw new IllegalStateException ("e=" + Arrays .toString (e .point ()) +
@@ -101,26 +100,26 @@ BTNode<T> tryPut(PointEntry<T> e, int maxNodeSize, boolean enforceLeaf) {
101
100
splitDim = d ;
102
101
}
103
102
}
104
- double splitValue = ordered [splitDim ][values .size () / 2 ];
103
+ double splitValue = ordered [splitDim ][vals .size () / 2 ];
105
104
106
- ArrayList <PointEntry <T >> left = new ArrayList <>();
107
- ArrayList <PointEntry <T >> right = new ArrayList <>();
105
+ ArrayList <PointEntry <T >> leftPoints = new ArrayList <>();
106
+ ArrayList <PointEntry <T >> rightPoints = new ArrayList <>();
108
107
for (int i = 0 ; i < vals .size (); i ++) {
109
108
PointEntry <T > pe = vals .get (i );
110
109
if (pe .point ()[splitDim ] >= splitValue ) {
111
- right .add (pe );
110
+ rightPoints .add (pe );
112
111
} else {
113
- left .add (pe );
112
+ leftPoints .add (pe );
114
113
}
115
114
}
116
115
117
116
double [] centerLeft = new double [dims ];
118
117
double [] centerRight = new double [dims ];
119
- double radiusLeft = BTUtil .calcBoundingSphere (left , centerLeft );
120
- double radiusRight = BTUtil .calcBoundingSphere (left , centerRight );
118
+ double radiusLeft = BTUtil .calcBoundingSphere (leftPoints , centerLeft );
119
+ double radiusRight = BTUtil .calcBoundingSphere (rightPoints , centerRight );
121
120
122
- this .left = new BTNode <>(centerLeft , radiusLeft , this , left );
123
- this .right = new BTNode <>(centerRight , radiusRight , this , right );
121
+ this .left = new BTNode <>(centerLeft , radiusLeft , this , leftPoints );
122
+ this .right = new BTNode <>(centerRight , radiusRight , this , rightPoints );
124
123
125
124
return findBestChildForInsert (e );
126
125
}
@@ -155,25 +154,6 @@ private BTNode<T> findBestChildForInsert(PointEntry<T> e) {
155
154
return resizeVolLeft > resizeVolRight ? this .right : this .left ;
156
155
}
157
156
158
-
159
- /**
160
- * The subnode position has reverse ordering of the point's
161
- * dimension ordering. Dimension 0 of a point is the highest
162
- * ordered bit in the position.
163
- * @param p point
164
- * @return subnode position
165
- */
166
- private int calcSubPosition (double [] p ) {
167
- int subNodePos = 0 ;
168
- for (int d = 0 ; d < center .length ; d ++) {
169
- subNodePos <<= 1 ;
170
- if (p [d ] >= center [d ]) {
171
- subNodePos |= 1 ;
172
- }
173
- }
174
- return subNodePos ;
175
- }
176
-
177
157
PointEntry <T > remove (BTNode <T > parent , double [] key , int maxNodeSize , Predicate <PointEntry <T >> pred ) {
178
158
if (!isLeaf ()) {
179
159
if (DIST .dist (left .center , key ) <= left .radius ) {
0 commit comments