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


Java Multisets.copyHighestCountFirst方法代碼示例

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


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

示例1: identifyDuplicates

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
private void identifyDuplicates(List<ModContainer> mods)
{
    TreeMultimap<ModContainer, File> dupsearch = TreeMultimap.create(new ModIdComparator(), Ordering.arbitrary());
    for (ModContainer mc : mods)
    {
        if (mc.getSource() != null)
        {
            dupsearch.put(mc, mc.getSource());
        }
    }

    ImmutableMultiset<ModContainer> duplist = Multisets.copyHighestCountFirst(dupsearch.keys());
    SetMultimap<ModContainer, File> dupes = LinkedHashMultimap.create();
    for (Entry<ModContainer> e : duplist.entrySet())
    {
        if (e.getCount() > 1)
        {
            FMLLog.severe("Found a duplicate mod %s at %s", e.getElement().getModId(), dupsearch.get(e.getElement()));
            dupes.putAll(e.getElement(),dupsearch.get(e.getElement()));
        }
    }
    if (!dupes.isEmpty())
    {
        throw new DuplicateModsFoundException(dupes);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:Loader.java

示例2: determinePayOutPercentage

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
/**
 * Method should return the number of times an occurrence of a reel
 * 
 * @param reels
 * @return
 */
static int determinePayOutPercentage(List<String> reels) {

	Multiset<String> reelCount = HashMultiset.create();
	reelCount.addAll(reels);

	// order the number of elements by the higest
	ImmutableMultiset<String> highestCountFirst = Multisets.copyHighestCountFirst(reelCount);

	int count = 0;
	for (Entry<String> entry : highestCountFirst.entrySet()) {
		count = entry.getCount();
		break;
	}
	return count;
}
 
開發者ID:leveluplunch,項目名稱:levelup-java-exercises,代碼行數:22,代碼來源:SlotMachineSimulation.java

示例3: test

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
@Test
public void test() {
    Multiset<String> multiset = HashMultiset.create();
    multiset.add("abc", 100);
    multiset.add("abc", 200);

    Multisets.copyHighestCountFirst(multiset);
}
 
開發者ID:bingoohuang,項目名稱:javacode-demo,代碼行數:9,代碼來源:MultisetTest.java

示例4: getMostUsedArticleCasing

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
public String getMostUsedArticleCasing() {
	HashMultiset<String> articleNames = HashMultiset.create();
	String result;

	for (Writable writable: super.get()) {
		LinkWritable link = (LinkWritable)writable;
		articleNames.add(link.getArticle().toString());
	}

	ImmutableMultiset<String> sorted = Multisets.copyHighestCountFirst(articleNames);
	result = (String)sorted.elementSet().toArray()[0];
	
	return result;
}
 
開發者ID:rossf7,項目名稱:wikireverse,代碼行數:15,代碼來源:LinkArrayWritable.java

示例5: topNTerms

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
public Set<String> topNTerms(String phrase, int topN) throws IOException {
	Set<String> result = new HashSet<String>();
	Multiset<String> terms = HashMultiset.create();
	// find most common number of columns throughout all rows
	TokenStream ts;
	CharTermAttribute cta;

	if (phrase.length() == 0)
		return result;
	ts = analyzer.tokenStream(null, new StringReader(phrase));
	cta = ts.addAttribute(CharTermAttribute.class);
	ts.reset();
	while (ts.incrementToken())
		terms.add(cta.toString());
	ts.end();
	ts.close();

	terms = Multisets.copyHighestCountFirst(terms);
	Iterator<String> iter = terms.elementSet().iterator();
	while(iter.hasNext()) {
		String s = iter.next();
		if (topN==0)
			break;
		result.add(s);
		topN--;
	}
	return result;
}
 
開發者ID:JulianEberius,項目名稱:dwtc-extractor,代碼行數:29,代碼來源:LuceneNormalizer.java

示例6: toView

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
@Override
public Top10UniqueVisitorsView toView() {
    uniqueVistors = Multisets.copyHighestCountFirst(uniqueVistors);
    Iterator<String> visitors = uniqueVistors.elementSet().iterator();
    int i = 0;
    Top10UniqueVisitorsView view = new Top10UniqueVisitorsView();
    while(visitors.hasNext() && i < 10){
        String ip = visitors.next();
        int visitCount = uniqueVistors.count(ip);
        view.addVisitor(ip, visitCount);
        i++;
    }
    return view;
}
 
開發者ID:nezhazheng,項目名稱:analysislog,代碼行數:15,代碼來源:Top10UniqueVisitorsAnalyzer.java

示例7: getMostPopularRowFirst

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
public Multiset<TRow> getMostPopularRowFirst() {
	return Multisets.copyHighestCountFirst(tRowCount);
}
 
開發者ID:mast-group,項目名稱:codemining-treelm,代碼行數:4,代碼來源:ElementCooccurence.java

示例8: groupBy

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
private Multiset<String> groupBy(Set<Id> ids, Function<Id, String> f) {
	Multiset<String> ms = HashMultiset.create();
	Iterables.addAll(ms, FluentIterable.from(ids).transform(f));
	return Multisets.copyHighestCountFirst(ms);
}
 
開發者ID:pfichtner,項目名稱:jrunalyzer,代碼行數:6,代碼來源:OverallStatsPanel.java

示例9: calculateMostRun

import com.google.common.collect.Multisets; //導入方法依賴的package包/類
private String calculateMostRun(Set<Id> allIds) throws IOException {
	Multiset<Id> ms = HashMultiset.create();
	for (Id id : allIds) {
		ms.add(id,
				OverallStatsPanel.this.dsf.getSimilarTracks(id).size() + 1);
	}
	Id top = Iterables.get(Multisets.copyHighestCountFirst(ms), 0);
	if (top == null) {
		return null;
	}

	Set<Id> similarTracks = ImmutableSet.<Id> builder().add(top)
			.addAll(this.dsf.getSimilarTracks(top)).build();
	FluentIterable<Metadata> metadata = FluentIterable.from(similarTracks)
			.transform(this.id2track).transform(Functions.Tracks.metadata);

	// do the have a common description?
	Multiset<String> desc = Multisets.copyHighestCountFirst(HashMultiset
			.create(metadata.transform(Functions.Metadatas.description)
					.filter(notNull()).filter(notEmpty())));
	String cd = desc.size() > 0 ? Iterables.get(desc, 0) : ""; //$NON-NLS-1$

	// do the have a common name?
	Multiset<String> names = Multisets.copyHighestCountFirst(HashMultiset
			.create(metadata.transform(Functions.Metadatas.name)
					.filter(notNull()).filter(notEmpty())));
	String cn = names.size() > 0 ? Iterables.get(names, 0) : ""; //$NON-NLS-1$

	String val;
	if (desc.count(cd) > desc.size() / 2) {
		val = cd;
	} else if (names.count(cn) > names.size() / 2) {
		val = cn;
	} else if (!desc.isEmpty()) {
		val = Joiner.on(", ").join(desc); //$NON-NLS-1$
	} else if (!names.isEmpty()) {
		val = Joiner.on(", ").join(names); //$NON-NLS-1$
	} else {
		val = "???"; //$NON-NLS-1$
	}
	return getI18n()
			.getText(
					"com.github.pfichtner.jrunalyser.ui.overallstats.OverallStatsPanel.mostRun.format", val, //$NON-NLS-1$
					Integer.valueOf(similarTracks.size()));
}
 
開發者ID:pfichtner,項目名稱:jrunalyzer,代碼行數:46,代碼來源:OverallStatsPanel.java


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