當前位置: 首頁>>代碼示例>>Java>>正文


Java Multisets.removeOccurrences方法代碼示例

本文整理匯總了Java中com.google.common.collect.Multisets.removeOccurrences方法的典型用法代碼示例。如果您正苦於以下問題:Java Multisets.removeOccurrences方法的具體用法?Java Multisets.removeOccurrences怎麽用?Java Multisets.removeOccurrences使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.Multisets的用法示例。


在下文中一共展示了Multisets.removeOccurrences方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: update

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
private void update() {
    ArrayList<UUID> onlinePlayers = new ArrayList<UUID>();
    for (Object obj : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList()) {
        EntityPlayerMP player = (EntityPlayerMP) obj;
        UUID uuid = player.getUniqueID();

        onlinePlayers.add(uuid);
        timeOnCount.add(uuid);

        //Kick players who are on too long
        if ((maxTimeOn.containsKey(uuid) && timeOnCount.count(uuid) > maxTimeOn.get(uuid)) || (maxTimeOnGlobal != 0 && timeOnCount.count(uuid) > maxTimeOnGlobal)) {
            rejoinTime.put(uuid, System.currentTimeMillis() + (breakTime.containsKey(uuid) ? breakTime.get(uuid) * 50 : breakTimeGlobal * 50));
            kickPlayerForTime(player);
            timeOnCount.remove(uuid, timeOnCount.count(uuid));
        }
    }

    //Decrease timeOnCount time for players that aren't online
    HashMultiset<UUID> uuids = HashMultiset.create();
    for (UUID entry : timeOnCount.elementSet()) {
        if (!onlinePlayers.contains(entry)) {
            uuids.add(entry);
        }
    }
    Multisets.removeOccurrences(timeOnCount, uuids);
}
 
開發者ID:kihira,項目名稱:BeProductive,代碼行數:27,代碼來源:BeProductive.java

示例2: findMinimalCoveringSet

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
private List<Pattern> findMinimalCoveringSet(List<Pattern> sortedPatterns, List<String> types) {

		List<Pattern> minimalSet = new LinkedList<Pattern>();
		
		Multiset<String> sourceTypes = HashMultiset.create(types);
//		Multiset<String> coveredTypes = HashMultiset.create();
		
		for (Pattern p : sortedPatterns) {
			Multiset<String> patternTypes = HashMultiset.create(p.getTypes());
			Multiset<String> patternCommonTypes = Multisets.intersection(patternTypes, sourceTypes);
//			if (Multisets.containsOccurrences(coveredTypes, patternCommonTypes)) // this pattern does not cover any new source type
			if (patternCommonTypes.size() == 0) // this pattern does not cover any new source type
				continue;
			else {
				minimalSet.add(p);
//				coveredTypes.addAll(patternCommonTypes);
				Multisets.removeOccurrences(sourceTypes, patternCommonTypes);
			}
//			if (Multisets.containsOccurrences(coveredTypes, sourceTypes))
			if (sourceTypes.size() == 0)
				break;
		}
		return minimalSet;
	}
 
開發者ID:therelaxist,項目名稱:spring-usc,代碼行數:25,代碼來源:ModelLearner_LOD_Greedy.java

示例3: performOp

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
@Override
public int performOp(final FoldableNode fn, final int prev, final HashMap<FoldableNode, Option> options) {

	// If node is folded, calculate profit
	double profit = 0;
	if (!fn.isUnfolded) {

		// Add current node terms to unfolded
		unfoldedTerms.addAll(fn.getTermFreqs());

		// Calculate tf-idf weights
		final TokenVector tv = new TokenVector(unfoldedTerms);

		// Get VSM profit
		if (set.profitType.equals("CSimFile"))
			profit = tv.cosSim(fileVec);
		else
			throw new RuntimeException("Incorrect profit function!");

		// Remove current node terms from unfolded
		Multisets.removeOccurrences(unfoldedTerms, fn.getTermFreqs());

		if (profit < 0) {
			System.out.println("Profit: " + profit);
			throw new RuntimeException("Profit must be positive!");
		}

		// If node has no terms, never unfold it
		if (fn.termFreqs.isEmpty())
			profit = Double.NEGATIVE_INFINITY;

	}

	// If node is unfolded, cost is zero
	if (fn.isUnfolded) {
		options.put(fn, new Option(0, profit));
		return 0; // Ignore for accumulated cost
	}

	// Else cost is node LOC minus child nodes LOC
	final int cost = prev + fn.getUniqueNodeCost();
	if (cost < 0)
		throw new RuntimeException("Cost must be positive!");
	options.put(fn, new Option(cost, profit));
	return cost; // Return accumulated cost

}
 
開發者ID:mast-group,項目名稱:tassal,代碼行數:48,代碼來源:FoldableTree.java


注:本文中的com.google.common.collect.Multisets.removeOccurrences方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。