本文整理了Java中net.imglib2.util.Util.quicksort()
方法的一些代码示例,展示了Util.quicksort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.quicksort()
方法的具体详情如下:
包路径:net.imglib2.util.Util
类名称:Util
方法名:quicksort
暂无
代码示例来源:origin: imglib/imglib2
public static void quicksort( final double[] data )
{
quicksort( data, 0, data.length - 1 );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final long[] data )
{
quicksort( data, 0, data.length - 1 );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final double[] data )
{
quicksort( data, 0, data.length - 1 );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final float[] data )
{
quicksort( data, 0, data.length - 1 );
}
代码示例来源:origin: imglib/imglib2
public static void quicksort( final long[] data )
{
quicksort( data, 0, data.length - 1 );
}
代码示例来源:origin: imglib/imglib2
public static void quicksort( final float[] data )
{
quicksort( data, 0, data.length - 1 );
}
代码示例来源:origin: imglib/imglib2
public static void quicksort( final float[] data, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final float x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final float temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, left, j );
if ( i < right )
quicksort( data, i, right );
}
代码示例来源:origin: imglib/imglib2
public static void quicksort( final long[] data, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final long x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final long temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, left, j );
if ( i < right )
quicksort( data, i, right );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final double[] data, final int[] sortAlso, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final double x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final double temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
final int temp2 = sortAlso[ i ];
sortAlso[ i ] = sortAlso[ j ];
sortAlso[ j ] = temp2;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, sortAlso, left, j );
if ( i < right )
quicksort( data, sortAlso, i, right );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final long[] data, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final long x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final long temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, left, j );
if ( i < right )
quicksort( data, i, right );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final double[] data, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final double x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final double temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, left, j );
if ( i < right )
quicksort( data, i, right );
}
代码示例来源:origin: imglib/imglib2
public static void quicksort( final double[] data, final int[] sortAlso, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final double x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final double temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
final int temp2 = sortAlso[ i ];
sortAlso[ i ] = sortAlso[ j ];
sortAlso[ j ] = temp2;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, sortAlso, left, j );
if ( i < right )
quicksort( data, sortAlso, i, right );
}
代码示例来源:origin: net.imglib2/imglib2
public static void quicksort( final float[] data, final int left, final int right )
{
if ( data == null || data.length < 2 )
return;
int i = left, j = right;
final float x = data[ ( left + right ) / 2 ];
do
{
while ( data[ i ] < x )
i++;
while ( x < data[ j ] )
j--;
if ( i <= j )
{
final float temp = data[ i ];
data[ i ] = data[ j ];
data[ j ] = temp;
i++;
j--;
}
}
while ( i <= j );
if ( left < j )
quicksort( data, left, j );
if ( i < right )
quicksort( data, i, right );
}
代码示例来源:origin: net.imglib2/imglib2
public static float median( final float[] values )
{
final float temp[] = values.clone();
float median;
final int length = temp.length;
quicksort( temp, 0, length - 1 );
if ( length % 2 == 1 ) // odd length
median = temp[ length / 2 ];
else
// even length
median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2;
return median;
}
代码示例来源:origin: net.imglib2/imglib2
public static double median( final double[] values )
{
final double temp[] = values.clone();
double median;
final int length = temp.length;
quicksort( temp, 0, length - 1 );
if ( length % 2 == 1 ) // odd length
median = temp[ length / 2 ];
else
// even length
median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2;
return median;
}
代码示例来源:origin: net.imglib2/imglib2
public static long median( final long[] values )
{
final long temp[] = values.clone();
long median;
final int length = temp.length;
quicksort( temp, 0, length - 1 );
if ( length % 2 == 1 ) // odd length
median = temp[ length / 2 ];
else
// even length
median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2;
return median;
}
代码示例来源:origin: imglib/imglib2
public static long median( final long[] values )
{
final long temp[] = values.clone();
long median;
final int length = temp.length;
quicksort( temp, 0, length - 1 );
if ( length % 2 == 1 ) // odd length
median = temp[ length / 2 ];
else
// even length
median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2;
return median;
}
代码示例来源:origin: imglib/imglib2
public static double median( final double[] values )
{
final double temp[] = values.clone();
double median;
final int length = temp.length;
quicksort( temp, 0, length - 1 );
if ( length % 2 == 1 ) // odd length
median = temp[ length / 2 ];
else
// even length
median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2;
return median;
}
代码示例来源:origin: imglib/imglib2
public static float median( final float[] values )
{
final float temp[] = values.clone();
float median;
final int length = temp.length;
quicksort( temp, 0, length - 1 );
if ( length % 2 == 1 ) // odd length
median = temp[ length / 2 ];
else
// even length
median = ( temp[ length / 2 ] + temp[ ( length / 2 ) - 1 ] ) / 2;
return median;
}
代码示例来源:origin: imglib/imglib2
@Test
public void testPercentile()
{
final double[] data = new double[42];
for(int i = 0; i < data.length; i++) {
data[i] = Math.random()*42;
}
final double[] sortedData = data.clone();
final double[] quicksortedData = data.clone();
Arrays.sort( sortedData );
quicksort( quicksortedData );
for(int i = 0; i < 3; i++){
double percentile = Math.random();
int pos = Math.min( data.length - 1,
Math.max( 0, ( int ) Math.round( ( data.length - 1 ) * percentile ) ) );
final double percentileRes = percentile( data, percentile );
assertEquals(quicksortedData[pos], sortedData[pos], 0.001);
assertEquals(quicksortedData[pos], percentileRes, 0.001);
}
}
内容来源于网络,如有侵权,请联系作者删除!