本文整理汇总了Java中gnu.trove.procedure.TObjectDoubleProcedure类的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleProcedure类的具体用法?Java TObjectDoubleProcedure怎么用?Java TObjectDoubleProcedure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TObjectDoubleProcedure类属于gnu.trove.procedure包,在下文中一共展示了TObjectDoubleProcedure类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retainEntries
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/**
* Retains only those entries in the map for which the procedure
* returns a true value.
*
* @param procedure determines which entries to keep
* @return true if the map was modified.
*/
public boolean retainEntries( TObjectDoubleProcedure<? super K> procedure ) {
boolean modified = false;
//noinspection unchecked
K[] keys = ( K[] ) _set;
double[] values = _values;
// Temporarily disable compaction. This is a fix for bug #1738760
tempDisableAutoCompaction();
try {
for ( int i = keys.length; i-- > 0; ) {
if ( keys[i] != FREE
&& keys[i] != REMOVED
&& ! procedure.execute( keys[i], values[i] ) ) {
removeAt(i);
modified = true;
}
}
}
finally {
reenableAutoCompaction( true );
}
return modified;
}
示例2: toString
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/** {@inheritDoc} */
public String toString() {
final StringBuilder buf = new StringBuilder("{");
forEachEntry( new TObjectDoubleProcedure<K>() {
private boolean first = true;
public boolean execute( K key, double value ) {
if ( first ) first = false;
else buf.append( "," );
buf.append( key ).append( "=" ).append( value );
return true;
}
});
buf.append( "}" );
return buf.toString();
}
示例3: retainEntries
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/**
* Retains only those entries in the map for which the procedure
* returns a true value.
*
* @param procedure determines which entries to keep
* @return true if the map was modified.
*/
public boolean retainEntries(final TObjectDoubleProcedure<? super K> procedure ) {
boolean modified = false;
//noinspection unchecked
final K[] keys = ( K[] ) _set;
final double[] values = _values;
// Temporarily disable compaction. This is a fix for bug #1738760
tempDisableAutoCompaction();
try {
for ( int i = keys.length; i-- > 0; ) {
if ( keys[i] != FREE
&& keys[i] != REMOVED
&& ! procedure.execute( keys[i], values[i] ) ) {
removeAt(i);
modified = true;
}
}
}
finally {
reenableAutoCompaction( true );
}
return modified;
}
示例4: toString
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/** {@inheritDoc} */
public String toString() {
final StringBuilder buf = new StringBuilder("{");
forEachEntry( new TObjectDoubleProcedure<K>() {
private boolean first = true;
public boolean execute(final K key, final double value ) {
if ( first ) first = false;
else buf.append( "," );
buf.append( key ).append( "=" ).append( value );
return true;
}
});
buf.append( "}" );
return buf.toString();
}
示例5: toString
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
@Override
public String toString() {
final StringBuilder ret = new StringBuilder();
ret.append("{");
values.forEachEntry(new TObjectDoubleProcedure<KeyArgs>() {
boolean notFirst = false;
@Override
public boolean execute(KeyArgs a, double b) {
if (notFirst) {
ret.append(", ");
}
ret.append(a);
ret.append("=");
ret.append(String.format("%.3f", b));
notFirst = true;
return true;
}
});
ret.append("}");
return ret.toString();
}
示例6: toString
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public String toString() {
final StringBuilder buf = new StringBuilder("{");
forEachEntry( new TObjectDoubleProcedure<K>() {
private boolean first = true;
@Override
public boolean execute( K key, double value ) {
if ( first ) first = false;
else buf.append( "," );
buf.append( key ).append( "=" ).append( value );
return true;
}
});
buf.append( "}" );
return buf.toString();
}
示例7: retainEntries
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/**
* Retains only those entries in the map for which the procedure
* returns a true value.
*
* @param procedure determines which entries to keep
* @return true if the map was modified.
*/
public boolean retainEntries( TObjectDoubleProcedure<K> procedure ) {
boolean modified = false;
//noinspection unchecked
K[] keys = ( K[] ) _set;
double[] values = _values;
// Temporarily disable compaction. This is a fix for bug #1738760
tempDisableAutoCompaction();
try {
for ( int i = keys.length; i-- > 0; ) {
if ( keys[i] != FREE
&& keys[i] != REMOVED
&& ! procedure.execute( keys[i], values[i] ) ) {
removeAt(i);
modified = true;
}
}
}
finally {
reenableAutoCompaction( true );
}
return modified;
}
示例8: argmax
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
/** Returns the key in map that has the greatest score */
public static Object argmax (TObjectDoubleHashMap map)
{
// A local class! Yes, Virginia, this is legal Java.
class Accumulator implements TObjectDoubleProcedure {
double bestVal = Double.NEGATIVE_INFINITY;
Object bestObj = null;
public boolean execute (Object a, double b)
{
if (b > bestVal) {
bestVal = b;
bestObj = a;
}
return true;
}
}
Accumulator procedure = new Accumulator ();
map.forEachEntry (procedure);
return procedure.bestObj;
}
示例9: estimateProbability
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
@Override
public double estimateProbability(double[] sample) {
final double[] prob = new double[1];
final int[] count = new int[1];
tree.coordinateRadiusSearch(sample, kernel.getCutOff() * getBandwidth(), new TObjectDoubleProcedure<double[]>() {
@Override
public boolean execute(double[] point, double distance) {
prob[0] += kernel.evaluate(Math.sqrt(distance) / getBandwidth());
count[0]++;
return true;
}
});
return prob[0] / (getBandwidth() * count[0]);
}
示例10: getDetailReport
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
@Override
public String getDetailReport() {
final StringBuilder outBuffer = new StringBuilder();
allScores.forEachEntry(new TObjectDoubleProcedure<QUERY>() {
@Override
public boolean execute(QUERY a, double b) {
String id;
if (a instanceof Identifiable)
id = ((Identifiable) a).getID();
else
id = a.toString();
outBuffer.append(String.format("[email protected]%-11s\t%10s\t%6.4f\n", N, id, b));
return true;
}
});
outBuffer.append("\n");
outBuffer.append(getSummaryReport());
return outBuffer.toString();
}
示例11: getFitnessDistribution
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
private EnumeratedDistribution<E> getFitnessDistribution(
final TObjectDoubleMap<E> entityFitnessMap, RandomGenerator random) {
if (entityFitnessMap.isEmpty()) {
return null;
}
double sum = 0;
for (Double fitness : entityFitnessMap.values()) {
sum += fitness;
}
final double fitnessSum = sum;
final List<Pair<E, Double>> pmf = new ArrayList<>();
entityFitnessMap.forEachEntry(new TObjectDoubleProcedure<E>() {
@Override
public boolean execute(E entity, double value) {
if (fitnessSum != 0) {
pmf.add(new Pair<>(entity, value));
} else {
pmf.add(new Pair<>(entity, 1.0D / entityFitnessMap.size()));
}
return true;
}
});
return new EnumeratedDistribution<>(random, pmf);
}
示例12: sortMetrics
import gnu.trove.procedure.TObjectDoubleProcedure; //导入依赖的package包/类
private static void sortMetrics(TObjectDoubleMap<String> metrics, final List<String> activities, final List<Double> values) {
metrics.forEachEntry(new TObjectDoubleProcedure<String>() {
public boolean execute(String s, double v) {
boolean inserted = false;
for (int i = 0; i < values.size() && i < METRIC_LINES; i++) {
if (v > values.get(i)) {
values.add(i, v);
activities.add(i, s);
inserted = true;
break;
}
}
if (!inserted && values.size() < METRIC_LINES) {
activities.add(s);
values.add(v);
}
return true;
}
});
}