本文整理汇总了Java中com.google.common.collect.Multiset.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java Multiset.Entry方法的具体用法?Java Multiset.Entry怎么用?Java Multiset.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Multiset
的用法示例。
在下文中一共展示了Multiset.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAttributeNamesForDuplicates
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
private void checkAttributeNamesForDuplicates(ValueType type, Protoclass protoclass) {
if (!type.attributes.isEmpty()) {
Multiset<String> attributeNames = HashMultiset.create(type.attributes.size());
for (ValueAttribute attribute : type.attributes) {
attributeNames.add(attribute.name());
}
List<String> duplicates = Lists.newArrayList();
for (Multiset.Entry<String> entry : attributeNames.entrySet()) {
if (entry.getCount() > 1) {
duplicates.add(entry.getElement());
}
}
if (!duplicates.isEmpty()) {
protoclass.report()
.error("Duplicate attribute names %s. You should check if correct @Value.Style applied",
duplicates);
}
}
}
示例2: writeResult
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@Override
public void writeResult(final List<EALScorer2015Style.Result> perDocResults,
final File eventTypesDir) throws IOException {
final Multiset<Symbol> eventTypesSeen = gatherEventTypesSeen(perDocResults);
for (final Multiset.Entry<Symbol> typeEntry : Multisets.copyHighestCountFirst(eventTypesSeen)
.entrySet()) {
final Symbol type = typeEntry.getElement();
final Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult>
filterFunction =
new Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult>() {
@Override
public EALScorer2015Style.ArgResult apply(final
EALScorer2015Style.ArgResult input) {
return input.copyFiltered(compose(equalTo(type), type()));
}
};
final File eventTypeDir = new File(eventTypesDir, type.asString());
eventTypeDir.mkdirs();
writeOverallArgumentScoresForTransformedResults(perDocResults, filterFunction,
eventTypeDir);
}
}
示例3: assertSetCount
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
private void assertSetCount(E element, int count) {
setCountCheckReturnValue(element, count);
assertEquals(
"multiset.count() should return the value passed to setCount()",
count,
getMultiset().count(element));
int size = 0;
for (Multiset.Entry<E> entry : getMultiset().entrySet()) {
size += entry.getCount();
}
assertEquals(
"multiset.size() should be the sum of the counts of all entries",
size,
getMultiset().size());
}
示例4: testEntrySet_iteratorRemovePropagates
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testEntrySet_iteratorRemovePropagates() {
Iterator<Multiset.Entry<E>> iterator = getMultiset().entrySet().iterator();
assertTrue(
"non-empty multiset.entrySet() iterator.hasNext() returned false", iterator.hasNext());
assertEquals(
"multiset.entrySet() iterator.next() returned incorrect entry",
Multisets.immutableEntry(e0(), 1),
iterator.next());
assertFalse(
"size 1 multiset.entrySet() iterator.hasNext() returned true after next()",
iterator.hasNext());
iterator.remove();
assertTrue(
"multiset isn't empty after multiset.entrySet() iterator.remove()",
getMultiset().isEmpty());
}
示例5: testEntryReflectsIteratorRemove
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsIteratorRemove() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
assertEquals(3, entry.getCount());
Iterator<E> itr = getMultiset().iterator();
itr.next();
itr.remove();
assertEquals(2, entry.getCount());
itr.next();
itr.remove();
itr.next();
itr.remove();
assertEquals(0, entry.getCount());
}
示例6: expressionsAreParallel
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
/**
* Returns true if {@code atLeastM} of the expressions in the given column are the same kind.
*/
private static boolean expressionsAreParallel(
List<List<ExpressionTree>> rows, int column, int atLeastM) {
Multiset<Tree.Kind> nodeTypes = HashMultiset.create();
for (List<? extends ExpressionTree> row : rows) {
if (column >= row.size()) {
continue;
}
nodeTypes.add(row.get(column).getKind());
}
for (Multiset.Entry<Tree.Kind> nodeType : nodeTypes.entrySet()) {
if (nodeType.getCount() >= atLeastM) {
return true;
}
}
return false;
}
示例7: observeSample
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@Override
public void observeSample(final Iterable<EALScorer2015Style.Result> perDocResults) {
// TODO: refactor this with non-bootstrapped version
final Multiset<Symbol>
eventTypesSeen = ByEventTypeResultWriter.gatherEventTypesSeen(perDocResults);
for (final Multiset.Entry<Symbol> typeEntry : Multisets.copyHighestCountFirst(eventTypesSeen)
.entrySet()) {
final Symbol type = typeEntry.getElement();
final Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult>
filterFunction =
new Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult>() {
@Override
public EALScorer2015Style.ArgResult apply(final
EALScorer2015Style.ArgResult input) {
return input
.copyFiltered(compose(equalTo(type), TypeRoleFillerRealisFunctions.type()));
}
};
final ImmutableList<EALScorer2015Style.ArgResult> relevantArgumentScores =
FluentIterable.from(perDocResults).transform(ByEventTypeResultWriter.GET_ARG_SCORES_ONLY)
.transform(filterFunction)
.toList();
eventTypeToArgScores.put(typeEntry.getElement().asString(),
AggregateResultWriter.computeArgScoresFromArgResults(relevantArgumentScores));
}
}
示例8: testEntryReflectsRemoveThenAdd
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require({SUPPORTS_REMOVE, SUPPORTS_ADD})
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsRemoveThenAdd() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
assertEquals(3, entry.getCount());
assertTrue(getMultiset().remove(e0()));
assertEquals(2, entry.getCount());
assertTrue(getMultiset().elementSet().remove(e0()));
assertEquals(0, entry.getCount());
getMultiset().add(e0(), 2);
assertEquals(2, entry.getCount());
}
示例9: testEntryReflectsElementSetClear
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsElementSetClear() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
assertEquals(3, entry.getCount());
getMultiset().elementSet().clear();
assertEquals(0, entry.getCount());
}
示例10: testEntryViewReflectsRemove
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryViewReflectsRemove() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
assertEquals(3, entry.getCount());
assertTrue(getMultiset().remove(e0()));
assertEquals(2, entry.getCount());
assertTrue(getMultiset().elementSet().remove(e0()));
assertEquals(0, entry.getCount());
}
示例11: create
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@Override
public Set<Multiset.Entry<E>> create(Object... entries) {
List<Object> contents = new ArrayList<Object>();
Set<E> elements = new HashSet<E>();
for (Object o : entries) {
@SuppressWarnings("unchecked")
Multiset.Entry<E> entry = (Entry<E>) o;
checkArgument(
elements.add(entry.getElement()), "Duplicate keys not allowed in EntrySetGenerator");
for (int i = 0; i < entry.getCount(); i++) {
contents.add(entry.getElement());
}
}
return ((Multiset<E>) gen.create(contents.toArray())).entrySet();
}
示例12: testEntryReflectsEntrySetClear
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsEntrySetClear() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
assertEquals(3, entry.getCount());
getMultiset().entrySet().clear();
assertEquals(0, entry.getCount());
}
示例13: testEntryReflectsEntrySetIteratorRemove
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsEntrySetIteratorRemove() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Iterator<Multiset.Entry<E>> entryItr = getMultiset().entrySet().iterator();
Multiset.Entry<E> entry = entryItr.next();
entryItr.remove();
assertEquals(0, entry.getCount());
}
示例14: testEntryReflectsClear
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(SEVERAL)
@CollectionFeature.Require(SUPPORTS_REMOVE)
@MultisetFeature.Require(ENTRIES_ARE_VIEWS)
public void testEntryReflectsClear() {
initThreeCopies();
assertEquals(3, getMultiset().count(e0()));
Multiset.Entry<E> entry = Iterables.getOnlyElement(getMultiset().entrySet());
assertEquals(3, entry.getCount());
getMultiset().clear();
assertEquals(0, entry.getCount());
}
示例15: testKeysEntrySetIteratorRemove
import com.google.common.collect.Multiset; //导入方法依赖的package包/类
@CollectionSize.Require(ONE)
@CollectionFeature.Require(SUPPORTS_ITERATOR_REMOVE)
public void testKeysEntrySetIteratorRemove() {
Multiset<K> keys = multimap().keys();
Iterator<Multiset.Entry<K>> itr = keys.entrySet().iterator();
assertEquals(Multisets.immutableEntry(k0(), 1), itr.next());
itr.remove();
assertTrue(multimap().isEmpty());
}