本文整理匯總了Java中com.google.common.collect.Multiset.addAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Multiset.addAll方法的具體用法?Java Multiset.addAll怎麽用?Java Multiset.addAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Multiset
的用法示例。
在下文中一共展示了Multiset.addAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: tokenizeToMultiset
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public Multiset<String> tokenizeToMultiset(String input) {
// tokenizeToList is not reused here on purpose. Removing duplicate
// words early means these don't have to be tokenized multiple
// times. Increases performance.
Multiset<String> tokens = HashMultiset.create(input.length());
tokens.add(input);
Multiset<String> newTokens = HashMultiset.create(input.length());
for (Tokenizer t : tokenizers) {
for (String token : tokens) {
newTokens.addAll(t.tokenizeToList(token));
}
Multiset<String> swap = tokens;
tokens = newTokens;
newTokens = swap;
newTokens.clear();
}
return tokens;
}
示例2: testMultiset
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Test
public void testMultiset() {
String strWorld = "a,b,c,d,b,b,c";
String[] words = strWorld.split(",");
List<String> wordList = new ArrayList<>();
wordList.addAll(Arrays.asList(words));
Multiset<String> wordsMultiset = HashMultiset.create();
wordsMultiset.addAll(wordList);
wordsMultiset.forEachEntry((s, value) -> System.out.println(MessageFormat.format("string={0},value={1}",s,value)));
// wordsMultiset.forEach(s -> System.out.println("key=" + s + "||count=" + wordsMultiset.count(s)));
}