當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。