Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Apr 3, 2024
1 parent e296ad8 commit aada687
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/imglib2/KDTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public KDTreeImpl impl()
*/
public < L extends RealLocalizable > KDTree( final List< T > values, final List< L > positions )
{
this( verifySize(values, positions), values, positions );
this( verifySize( values, positions ), values, positions );
}

private static int verifySize( final List< ? > values, final List< ? > positions )
Expand All @@ -61,7 +61,7 @@ private static int verifySize( final List< ? > values, final List< ? > positions
* {@link IterableRealInterval}.
*
* @param interval
* elements in the tree are obtained by iterating this
* elements in the tree are obtained by iterating this
*/
public KDTree( final IterableRealInterval< T > interval )
{
Expand Down Expand Up @@ -129,16 +129,15 @@ public < L extends RealLocalizable > KDTree( final int numPoints, final Iterable
public KDTree( final KDTreeData< T > data )
{
treeData = data;
impl = new KDTreeImpl(treeData.positions);
impl = new KDTreeImpl( treeData.positions() );
}

/**
* Get the root node.
*
* @return the root node.
*
* @deprecated
* {@link KDTreeNode} is now a re-usable proxy (like {@code NativeType}).
* @deprecated {@link KDTreeNode} is now a re-usable proxy (like {@code NativeType}).
* To work with existing code, {@link KDTreeNode#left()}, {@link
* KDTreeNode#right()}, {@link KDTree#getRoot()} etc create new objects in each
* call, instead of re-using existing proxies.
Expand Down Expand Up @@ -253,7 +252,8 @@ private String toString( final int node, final String indent, final KDTreeNode<
* {@link KDTreeNode#setNodeIndex(int)} can be used to point the proxy to a
* particular node in the tree.
*/
public KDTreeNode< T > createNode() {
public KDTreeNode< T > createNode()
{
return new KDTreeNode<>( this );
}

Expand Down
18 changes: 10 additions & 8 deletions src/main/java/net/imglib2/kdtree/KDTreeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* / \ /
* 7 8 9
* </pre>
*
* <p>
* never like this:
* <pre>
* 0
Expand All @@ -35,7 +35,7 @@
* / / /
* 7 8 9
* </pre>
*
* <p>
* By choosing pivots in this way, the tree structure is fully
* determined. For every node index, the child indices can be calculated
* without dependent reads. And iff the calculated child index is less
Expand All @@ -49,7 +49,8 @@ public class KDTreeImpl

protected final KDTreePositions positions;

public KDTreeImpl(final KDTreePositions positions) {
public KDTreeImpl( final KDTreePositions positions )
{
this.numDimensions = positions.numDimensions;
this.numPoints = positions.numPoints;
this.positions = positions;
Expand Down Expand Up @@ -126,8 +127,9 @@ public int splitDimension( final int i )
return ( 31 - Integer.numberOfLeadingZeros( i + 1 ) ) % numDimensions;
}

public double getDoublePosition(final int i, final int d) {
return positions.get(i, d);
public double getDoublePosition( final int i, final int d )
{
return positions.get( i, d );
}

/**
Expand All @@ -138,7 +140,7 @@ public float squDistance( final int i, final float[] pos )
float sum = 0;
for ( int d = 0; d < numDimensions; ++d )
{
final float diff = pos[ d ] - ( float ) positions.get(i, d);
final float diff = pos[ d ] - ( float ) positions.get( i, d );
sum += diff * diff;
}
return sum;
Expand All @@ -152,7 +154,7 @@ public double squDistance( final int i, final double[] pos )
double sum = 0;
for ( int d = 0; d < numDimensions; ++d )
{
final double diff = pos[ d ] - positions.get(i, d);
final double diff = pos[ d ] - positions.get( i, d );
sum += diff * diff;
}
return sum;
Expand All @@ -166,7 +168,7 @@ public double squDistance( final int i, final RealLocalizable pos )
double sum = 0;
for ( int d = 0; d < numDimensions; ++d )
{
final double diff = pos.getDoublePosition( d ) - positions.get(i, d);
final double diff = pos.getDoublePosition( d ) - positions.get( i, d );
sum += diff * diff;
}
return sum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,4 @@ public KNearestNeighborSearchImpl copy()
System.arraycopy( bestSquDistance, 0, copy.bestSquDistance, 0, bestSquDistance.length );
return copy;
}

}

0 comments on commit aada687

Please sign in to comment.