本文整理匯總了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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例7: getMostPopularRowFirst
import com.google.common.collect.Multisets; //導入方法依賴的package包/類
public Multiset<TRow> getMostPopularRowFirst() {
return Multisets.copyHighestCountFirst(tRowCount);
}
示例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);
}
示例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()));
}