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


Java Multiset.Entry方法代碼示例

本文整理匯總了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);
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:ValueTypeComposer.java

示例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);
  }
}
 
開發者ID:isi-nlp,項目名稱:tac-kbp-eal,代碼行數:24,代碼來源:ByEventTypeResultWriter.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:18,代碼來源:AbstractMultisetSetCountTester.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:19,代碼來源:MultisetEntrySetTester.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:19,代碼來源:MultisetEntrySetTester.java

示例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;
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:20,代碼來源:JavaInputAstVisitor.java

示例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));
  }
}
 
開發者ID:isi-nlp,項目名稱:tac-kbp-eal,代碼行數:28,代碼來源:BootstrappedPerEventResultWriter.java

示例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());
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:16,代碼來源:MultisetEntrySetTester.java

示例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());
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:12,代碼來源:MultisetEntrySetTester.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:14,代碼來源:MultisetEntrySetTester.java

示例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();
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:16,代碼來源:MultisetTestSuiteBuilder.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:12,代碼來源:MultisetEntrySetTester.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:12,代碼來源:MultisetEntrySetTester.java

示例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());
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:12,代碼來源:MultisetEntrySetTester.java

示例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());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:10,代碼來源:MultimapKeysTester.java


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