当前位置: 首页>>代码示例>>Java>>正文


Java TObjectIntHashMap.forEachEntry方法代码示例

本文整理汇总了Java中gnu.trove.map.hash.TObjectIntHashMap.forEachEntry方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectIntHashMap.forEachEntry方法的具体用法?Java TObjectIntHashMap.forEachEntry怎么用?Java TObjectIntHashMap.forEachEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.map.hash.TObjectIntHashMap的用法示例。


在下文中一共展示了TObjectIntHashMap.forEachEntry方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postprocessQuery

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
/**
 * This method represents the last step that's executed when processing a query. A list of partial-results (DistanceElements) returned by
 * the lookup stage is processed based on some internal method and finally converted to a list of ScoreElements. The filtered list of
 * ScoreElements is returned by the feature module during retrieval.
 *
 * @param partialResults List of partial results returned by the lookup stage.
 * @param qc             A ReadableQueryConfig object that contains query-related configuration parameters.
 * @return List of final results. Is supposed to be de-duplicated and the number of items should not exceed the number of items per module.
 */
@Override
protected List<ScoreElement> postprocessQuery(List<SegmentDistanceElement> partialResults, ReadableQueryConfig qc) {
     /* Prepare helper data-structures. */
    final List<ScoreElement> results = new ArrayList<>();
    final TObjectIntHashMap<String> scoreMap = new TObjectIntHashMap<>();

     /* Set QueryConfig and extract correspondence function. */
    qc = this.setQueryConfig(qc);
    final CorrespondenceFunction correspondence = qc.getCorrespondenceFunction().orElse(this.linearCorrespondence);
    for (DistanceElement hit : partialResults) {
        if (hit.getDistance() < this.distanceThreshold) {
            scoreMap.adjustOrPutValue(hit.getId(), 1, scoreMap.get(hit.getId())/2);
        }
    }

    /* Prepare final result-set. */
    scoreMap.forEachEntry((key, value) -> results.add(new SegmentScoreElement(key, 1.0 - 1.0/value)));
    ScoreElement.filterMaximumScores(results.stream());
    return results;
}
 
开发者ID:vitrivr,项目名称:cineast,代码行数:30,代码来源:MFCCShingle.java

示例2: takeTop

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
public static <T> List<Weighted<T>> takeTop(int k, TObjectIntHashMap<T> objects) {
  TopKHeap<Weighted<T>> top = new TopKHeap<>(k);
  objects.forEachEntry((obj, count) -> {
    top.offer(new Weighted<>(count, obj));
    return true;
  });
  return top.getSorted();
}
 
开发者ID:jjfiv,项目名称:chai,代码行数:9,代码来源:TopKHeap.java

示例3: search

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
/**
 * Search for a given image (represented by its features) in the database
 *
 * @param features
 *            the features
 * @return the list of matching images and their scores (bigger == more
 *         chance of match)
 */
public List<ObjectIntPair<T>> search(int[][] features) {
	final TObjectIntHashMap<T> counter = new TObjectIntHashMap<>();

	for (final int[] sketch : features) {
		for (int i = 0; i < sketch.length; i++) {
			final int sk = sketch[i];
			final Set<T> s = database.get(i).get(sk);
			if (s != null) {
				for (final T key : s) {
					counter.adjustOrPutValue(key, 1, 1);
				}
			}
		}
	}

	final List<ObjectIntPair<T>> result = new ArrayList<>();

	counter.forEachEntry(new TObjectIntProcedure<T>() {
		@Override
		public boolean execute(T a, int b) {
			if (b > minScore)
				result.add(ObjectIntPair.pair(a, b));
			return false;
		}
	});

	Collections.sort(result, new Comparator<ObjectIntPair<T>>() {
		@Override
		public int compare(ObjectIntPair<T> o1, ObjectIntPair<T> o2) {
			return Integer.compare(o2.second, o1.second);
		}
	});

	return result;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:44,代码来源:BasicDuplicateImageDatabase.java

示例4: train

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
@Override
public void train(List<? extends Annotated<OBJECT, ANNOTATION>> data) {
	final TIntIntHashMap nAnnotationCounts = new TIntIntHashMap();
	final TObjectIntHashMap<ANNOTATION> annotationCounts = new TObjectIntHashMap<ANNOTATION>();
	int maxVal = 0;

	for (final Annotated<OBJECT, ANNOTATION> sample : data) {
		final Collection<ANNOTATION> annos = sample.getAnnotations();

		for (final ANNOTATION s : annos) {
			annotationCounts.adjustOrPutValue(s, 1, 1);
		}

		nAnnotationCounts.adjustOrPutValue(annos.size(), 1, 1);

		if (annos.size() > maxVal)
			maxVal = annos.size();
	}

	// build distribution and rng for each annotation
	annotations = new ArrayList<ANNOTATION>();
	final TDoubleArrayList probs = new TDoubleArrayList();
	annotationCounts.forEachEntry(new TObjectIntProcedure<ANNOTATION>() {
		@Override
		public boolean execute(ANNOTATION a, int b) {
			annotations.add(a);
			probs.add(b);
			return true;
		}
	});
	annotationProbability = new EmpiricalWalker(probs.toArray(), Empirical.NO_INTERPOLATION, new MersenneTwister());

	numAnnotations.train(data);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:IndependentPriorRandomAnnotator.java

示例5: findMatches

import gnu.trove.map.hash.TObjectIntHashMap; //导入方法依赖的package包/类
@Override
public boolean findMatches(List<T> queryfeatures) {
	matches = new ArrayList<Pair<T>>();

	final TObjectIntHashMap<T> targets = new TObjectIntHashMap<T>();

	for (final T query : queryfeatures) {
		final T modeltarget = findMatch(query, modelKeypoints);
		if (modeltarget == null)
			continue;

		final T querytarget = findMatch(modeltarget, queryfeatures);

		if (querytarget == query) {
			matches.add(new Pair<T>(query, modeltarget));
			targets.adjustOrPutValue(modeltarget, 1, 1);
		}
	}

	final ArrayList<Pair<T>> matchesToRemove = new ArrayList<Pair<T>>();
	targets.forEachEntry(new TObjectIntProcedure<T>() {
		@Override
		public boolean execute(T a, int b) {
			if (b > 1) {
				for (final Pair<T> p : matches) {
					if (p.secondObject() == a)
						matchesToRemove.add(p);
				}
			}
			return true;
		}
	});

	matches.removeAll(matchesToRemove);

	return matches.size() > 0;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:38,代码来源:BasicTwoWayMatcher.java


注:本文中的gnu.trove.map.hash.TObjectIntHashMap.forEachEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。