本文整理汇总了Java中cern.colt.list.DoubleArrayList.sort方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleArrayList.sort方法的具体用法?Java DoubleArrayList.sort怎么用?Java DoubleArrayList.sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.list.DoubleArrayList
的用法示例。
在下文中一共展示了DoubleArrayList.sort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by key.
*/
public String toString() {
DoubleArrayList theKeys = keys();
theKeys.sort();
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
double key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex) buf.append(", ");
}
buf.append("]");
return buf.toString();
}
示例2: bandwidthNRD
import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
public double bandwidthNRD(double[] in) {
DoubleArrayList inList = new DoubleArrayList(in.length);
for (double d : in)
inList.add(d);
inList.sort();
final double h = (Descriptive.quantile(inList, 0.75) - Descriptive.quantile(inList, 0.25)) / 1.34;
return 4 * 1.06 *
Math.min(Math.sqrt(DiscreteStatistics.variance(in)), h) *
Math.pow(in.length, -0.2);
}
示例3: bandwidthNRD
import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
public double bandwidthNRD(double[] in) {
DoubleArrayList inList = new DoubleArrayList(in.length);
for (double d : in)
inList.add(d);
inList.sort();
final double h = (Descriptive.quantile(inList, 0.75) - Descriptive
.quantile(inList, 0.25)) / 1.34;
return 4 * 1.06
* Math.min(Math.sqrt(DiscreteStatistics.variance(in)), h)
* Math.pow(in.length, -0.2);
}
示例4: pairsSortedByKey
import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
* Fills all keys and values <i>sorted ascending by key</i> into the specified lists.
* Fills into the lists, starting at index 0.
* After this call returns the specified lists both have a new size that equals <tt>this.size()</tt>.
* <p>
* <b>Example:</b>
* <br>
* <tt>keys = (8,7,6), values = (1,2,2) --> keyList = (6,7,8), valueList = (2,2,1)</tt>
*
* @param keyList the list to be filled with keys, can have any size.
* @param valueList the list to be filled with values, can have any size.
*/
public void pairsSortedByKey(final DoubleArrayList keyList, final IntArrayList valueList) {
/*
keys(keyList);
values(valueList);
final double[] k = keyList.elements();
final int[] v = valueList.elements();
cern.colt.Swapper swapper = new cern.colt.Swapper() {
public void swap(int a, int b) {
int t1; double t2;
t1 = v[a]; v[a] = v[b]; v[b] = t1;
t2 = k[a]; k[a] = k[b]; k[b] = t2;
}
};
cern.colt.function.IntComparator comp = new cern.colt.function.IntComparator() {
public int compare(int a, int b) {
return k[a]<k[b] ? -1 : k[a]==k[b] ? 0 : 1;
}
};
cern.colt.MultiSorting.sort(0,keyList.size(),comp,swapper);
*/
// this variant may be quicker
//cern.colt.map.OpenDoubleIntHashMap.hashCollisions = 0;
//System.out.println("collisions="+cern.colt.map.OpenDoubleIntHashMap.hashCollisions);
keys(keyList);
keyList.sort();
valueList.setSize(keyList.size());
for (int i=keyList.size(); --i >= 0; ) {
valueList.setQuick(i,get(keyList.getQuick(i)));
}
//System.out.println("collisions="+cern.colt.map.OpenDoubleIntHashMap.hashCollisions);
}