本文整理汇总了Java中gnu.trove.map.TObjectDoubleMap.forEachEntry方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectDoubleMap.forEachEntry方法的具体用法?Java TObjectDoubleMap.forEachEntry怎么用?Java TObjectDoubleMap.forEachEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TObjectDoubleMap
的用法示例。
在下文中一共展示了TObjectDoubleMap.forEachEntry方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFitnessDistribution
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的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);
}
示例2: sortMetrics
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的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;
}
});
}
示例3: segmentsFromSegmentsDistanceMap
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
static List<SegmentScoreElement> segmentsFromSegmentsDistanceMap(
TObjectDoubleMap<String> distanceBySegmentId, CorrespondenceFunction correspondence) {
ImmutableList.Builder<SegmentScoreElement> builder = ImmutableList.builder();
distanceBySegmentId.forEachEntry((id, score) -> {
builder.add(new SegmentScoreElement(id, correspondence.applyAsDouble(score)));
return true;
});
return builder.build();
}
示例4: normalizeSortTruncate
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
private List<SegmentScoreElement> normalizeSortTruncate(
TObjectDoubleMap<String> scoreBySegmentId) {
List<SegmentScoreElement> results = new ArrayList<>(scoreBySegmentId.size());
scoreBySegmentId.forEachEntry((segmentId, score) -> {
results.add(new SegmentScoreElement(segmentId, score / this.retrieverWeightSum));
return true;
});
results.sort(ScoreElement.SCORE_COMPARATOR.reversed());
if (results.size() > MAX_RESULTS) {
return results.subList(0, MAX_RESULTS);
} else {
return results;
}
}
示例5: putAll
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void putAll( TObjectDoubleMap<? extends K> map ){
map.forEachEntry( PUT_ALL_PROC );
}
示例6: putAll
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void putAll(final TObjectDoubleMap<? extends K> map ){
map.forEachEntry( PUT_ALL_PROC );
}
示例7: putAll
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public void putAll( TObjectDoubleMap<? extends K> map ){
map.forEachEntry( PUT_ALL_PROC );
}
示例8: putAll
import gnu.trove.map.TObjectDoubleMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void putAll( TObjectDoubleMap<K> map ){
map.forEachEntry( PUT_ALL_PROC );
}