本文整理匯總了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);
}
示例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;
}
示例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
}