本文整理汇总了Java中cern.colt.Sorting类的典型用法代码示例。如果您正苦于以下问题:Java Sorting类的具体用法?Java Sorting怎么用?Java Sorting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Sorting类属于cern.colt包,在下文中一共展示了Sorting类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: report
import cern.colt.Sorting; //导入依赖的package包/类
@Override
public Object report(Argument args[], Context context)
throws ExtensionException, LogoException {
LogoStatsTbl tbl = StatsExtension.getTblFromArgument(args[0]);
int varNumber = ExtnUtils.getVarNumberFromArg(tbl, args[1]);
double pcnt;
try {
pcnt = args[2].getDoubleValue();
} catch (LogoException e) {
throw new ExtensionException(e.getMessage());
}
pcnt /= 100.0;
if (pcnt < 0.0 || pcnt > 100.0) {
throw new ExtensionException("The percent must be between"
+ " 0.0 and 100.0, inclusive.");
}
double[] X = tbl.getColumn(varNumber, true);
Sorting.mergeSort(X, 0, X.length);
return Descriptive.quantile(new DoubleArrayList(X), pcnt);
}
开发者ID:cstaelin,项目名称:Stats-Extension,代码行数:21,代码来源:DescripPrims.java
示例2: get
import cern.colt.Sorting; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ImmutableSparseVector get( final Object o ) {
final T summary = (T)o;
final int nTerms = summary.size();
double[] scores = new double[ nTerms ];
final double[] scores2 = new double[ nTerms ];
int[] terms = new int[ nTerms ];
//final int totalOccourrences = summary.length();
for ( int i = 0; i < nTerms; i++ ) {
final int term = summary.term( i );
final int count = summary.count( i );
terms[ i ] = term;
scores[ i ] = scores2[ i ] = (double)count;// / (double)totalOccourrences;
}
double threshold = 0.0;
if ( cutAt > nTerms && cutAt < Integer.MAX_VALUE ) {
Sorting.mergeSort( scores2, 0, scores2.length );
threshold = scores2[ scores2.length - cutAt + 1 ];
}
return ImmutableSparseVector.getInstance( terms, scores, totalTerms, threshold, summary.id() );
}
开发者ID:corradomonti,项目名称:llamafur,代码行数:30,代码来源:FrequenciesFeaturizer.java
示例3: getOrder
import cern.colt.Sorting; //导入依赖的package包/类
/**
* Returns the order of the given sensitive attribute in the original dataset.
* Required for t-closeness.
*
* @param attribute
* @return distribution
*/
public int[] getOrder(String attribute) {
// Check
if (!indexesSensitive.containsKey(attribute)) {
throw new IllegalArgumentException("Attribute " + attribute + " is not sensitive");
}
// Prepare
final String[] dictionary = dataAnalyzed.getDictionary().getMapping()[indexesSensitive.get(attribute)];
final DataType<?> type = this.dataTypesSensitive.get(attribute);
// Init
int[] order = new int[dictionary.length];
for (int i = 0; i < order.length; i++) {
order[i] = i;
}
// Sort
Sorting.mergeSort(order, 0, order.length, new IntComparator() {
@Override public int compare(int arg0, int arg1) {
String value1 = dictionary[arg0];
String value2 = dictionary[arg1];
try {
return type.compare(value1, value2);
} catch (NumberFormatException | ParseException e) {
throw new IllegalStateException(e);
}
}
});
// Return
return order;
}
开发者ID:arx-deidentifier,项目名称:arx,代码行数:41,代码来源:DataManager.java
示例4: run
import cern.colt.Sorting; //导入依赖的package包/类
/**
* Run the benchmark
* @param size
*/
private static void run(int size) {
// Prepare
int[][] arrays = new int[REPETITIONS*3+3][];
for (int j=0; j<arrays.length; j++){
arrays[j] = new int[size];
}
Random random = new Random();
for (int j=0; j<arrays.length; j++){
for (int i=0; i<size; i++){
arrays[j][i] = random.nextInt();
}
}
int index = 0;
// Run colt merge sort
BENCHMARK.addRun(size, "ColtMergeSort");
Sorting.mergeSort(arrays[index++], 0, size); // Warm up
for (int i = 0; i < REPETITIONS; i++) {
BENCHMARK.startTimer(TIME);
Sorting.mergeSort(arrays[index++], 0, size);
BENCHMARK.addStopTimer(TIME);
}
// Run colt quick sort
IntComparator c = new IntComparator(){
public int compare(int arg0, int arg1) {
int result = arg0 < arg1 ? -1 : 0;
result = arg0 > arg1 ? +1 : 0;
return result;
}
};
BENCHMARK.addRun(size, "ColtQuickSort");
Sorting.quickSort(arrays[index++], 0, size, c); // Warm up
for (int i = 0; i < REPETITIONS; i++) {
BENCHMARK.startTimer(TIME);
Sorting.quickSort(arrays[index++], 0, size, c);
BENCHMARK.addStopTimer(TIME);
}
// Run java quick sort
BENCHMARK.addRun(size, "JavaQuickSort");
Sorting.mergeSort(arrays[index++], 0, size); // Warm up
for (int i = 0; i < REPETITIONS; i++) {
BENCHMARK.startTimer(TIME);
Arrays.sort(arrays[index++]);
BENCHMARK.addStopTimer(TIME);
}
}
开发者ID:prasser,项目名称:subframe,代码行数:56,代码来源:SortBenchmark.java
注:本文中的cern.colt.Sorting类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论