Java 类com.google.common.collect.Multisets 实例源码

项目:tac-kbp-eal    文件:ByEventTypeResultWriter.java   
@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);
  }
}
项目:guava-mock    文件:MultisetEntrySetTester.java   
@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());
}
项目:guava-mock    文件:MultisetNavigationTester.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  sortedMultiset = cast(getMultiset());
  entries =
      copyToList(
          getSubjectGenerator()
              .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
  Collections.sort(entries, sortedMultiset.comparator());

  // some tests assume SEVERAL == 3
  if (entries.size() >= 1) {
    a = Multisets.immutableEntry(entries.get(0), sortedMultiset.count(entries.get(0)));
    if (entries.size() >= 3) {
      b = Multisets.immutableEntry(entries.get(1), sortedMultiset.count(entries.get(1)));
      c = Multisets.immutableEntry(entries.get(2), sortedMultiset.count(entries.get(2)));
    }
  }
}
项目:googles-monorepo-demo    文件:MultisetEntrySetTester.java   
@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());
}
项目:googles-monorepo-demo    文件:MultisetNavigationTester.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  sortedMultiset = cast(getMultiset());
  entries =
      copyToList(
          getSubjectGenerator()
              .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
  Collections.sort(entries, sortedMultiset.comparator());

  // some tests assume SEVERAL == 3
  if (entries.size() >= 1) {
    a = Multisets.immutableEntry(entries.get(0), sortedMultiset.count(entries.get(0)));
    if (entries.size() >= 3) {
      b = Multisets.immutableEntry(entries.get(1), sortedMultiset.count(entries.get(1)));
      c = Multisets.immutableEntry(entries.get(2), sortedMultiset.count(entries.get(2)));
    }
  }
}
项目:CustomWorldGen    文件:FMLProxyPacket.java   
/**
 * Passes this Packet on to the NetHandler for processing.
 */
@Override
public void processPacket(INetHandler inethandler)
{
    this.netHandler = inethandler;
    EmbeddedChannel internalChannel = NetworkRegistry.INSTANCE.getChannel(this.channel, this.target);
    if (internalChannel != null)
    {
        internalChannel.attr(NetworkRegistry.NET_HANDLER).set(this.netHandler);
        try
        {
            if (internalChannel.writeInbound(this))
            {
                badPackets.add(this.channel);
                if (badPackets.size() % packetCountWarning == 0)
                {
                    FMLLog.severe("Detected ongoing potential memory leak. %d packets have leaked. Top offenders", badPackets.size());
                    int i = 0;
                    for (Entry<String> s  : Multisets.copyHighestCountFirst(badPackets).entrySet())
                    {
                        if (i++ > 10) break;
                        FMLLog.severe("\t %s : %d", s.getElement(), s.getCount());
                    }
                }
            }
            internalChannel.inboundMessages().clear();
        }
        catch (FMLNetworkException ne)
        {
            FMLLog.log(Level.ERROR, ne, "There was a network exception handling a packet on channel %s", channel);
            dispatcher.rejectHandshake(ne.getMessage());
        }
        catch (Throwable t)
        {
            FMLLog.log(Level.ERROR, t, "There was a critical exception handling a packet on channel %s", channel);
            dispatcher.rejectHandshake("A fatal error has occurred, this connection is terminated");
        }
    }
}
项目:CustomWorldGen    文件:Loader.java   
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);
    }
}
项目:TRHS_Club_Mod_2016    文件:Loader.java   
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);
    }
}
项目:intellij-ce-playground    文件:AttributesModelColorPaletteModel.java   
private void loadColors() {
  if (myResourceResolver == null) {
    myColorList = Collections.emptyList();
    return;
  }

  int rows = myModel.getRowCount();
  Multiset<Color> colorSet = HashMultiset.create();
  for (int i = 0; i < rows; i++) {
    if (myModel.getCellClass(i, 0) != Color.class) {
      continue;
    }

    EditedStyleItem item = (EditedStyleItem)myModel.getValueAt(i, 0);
    for (Color color : ResourceHelper.resolveMultipleColors(myResourceResolver, item.getItemResourceValue())) {
      myColorReferences.put(color, item);
      colorSet.add(color);
    }
  }

  myColorList = ImmutableList.copyOf(Multisets.copyHighestCountFirst(colorSet).elementSet());
}
项目:BeProductive    文件:BeProductive.java   
private void update() {
    ArrayList<UUID> onlinePlayers = new ArrayList<UUID>();
    for (Object obj : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerList()) {
        EntityPlayerMP player = (EntityPlayerMP) obj;
        UUID uuid = player.getUniqueID();

        onlinePlayers.add(uuid);
        timeOnCount.add(uuid);

        //Kick players who are on too long
        if ((maxTimeOn.containsKey(uuid) && timeOnCount.count(uuid) > maxTimeOn.get(uuid)) || (maxTimeOnGlobal != 0 && timeOnCount.count(uuid) > maxTimeOnGlobal)) {
            rejoinTime.put(uuid, System.currentTimeMillis() + (breakTime.containsKey(uuid) ? breakTime.get(uuid) * 50 : breakTimeGlobal * 50));
            kickPlayerForTime(player);
            timeOnCount.remove(uuid, timeOnCount.count(uuid));
        }
    }

    //Decrease timeOnCount time for players that aren't online
    HashMultiset<UUID> uuids = HashMultiset.create();
    for (UUID entry : timeOnCount.elementSet()) {
        if (!onlinePlayers.contains(entry)) {
            uuids.add(entry);
        }
    }
    Multisets.removeOccurrences(timeOnCount, uuids);
}
项目:CauldronGit    文件:Loader.java   
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);
    }
}
项目:guava-libraries    文件:MultisetEntrySetTester.java   
@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());
}
项目:guava-libraries    文件:MultimapKeysTester.java   
@CollectionSize.Require(SEVERAL)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testKeysWithNullKey() {
  resetContainer(
      Helpers.mapEntry((K) null, v0()),
      Helpers.mapEntry((K) null, v1()),
      Helpers.mapEntry(k1(), v0()));
  Multiset<K> keys = multimap().keys();
  assertEquals(2, keys.count(null));
  assertEquals(1, keys.count(k1()));
  assertEquals(3, keys.size());
  assertThat(keys).containsAllOf(null, k1());
  assertThat(keys.entrySet()).containsAllOf(
      Multisets.immutableEntry((K) null, 2),
      Multisets.immutableEntry(k1(), 1));
}
项目:guava-libraries    文件:MultisetNavigationTester.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  sortedMultiset = cast(getMultiset());
  entries =
      copyToList(getSubjectGenerator().getSampleElements(
          getSubjectGenerator().getCollectionSize().getNumElements()));
  Collections.sort(entries, sortedMultiset.comparator());

  // some tests assume SEVERAL == 3
  if (entries.size() >= 1) {
    a = Multisets.immutableEntry(entries.get(0), sortedMultiset.count(entries.get(0)));
    if (entries.size() >= 3) {
      b = Multisets.immutableEntry(entries.get(1), sortedMultiset.count(entries.get(1)));
      c = Multisets.immutableEntry(entries.get(2), sortedMultiset.count(entries.get(2)));
    }
  }
}
项目:codemining-treelm    文件:PrintImportPatternCovariance.java   
/**
 * Output to stdout the non-normalized vectors containing the
 * cross-correlation between packages and patterns.
 */
public void printTargetVectors() {

    final Multiset<String> packages = covariance.getElementCooccurence()
            .getRowMultiset();

    final List<String> topImports = getTopImports(packages);
    printTopImports(packages, topImports);

    final Set<Integer> topPatterns = getTopPatternsForImports(topImports);

    // Just add top patterns because of their count. This should be general
    // patterns
    for (final int patternId : Multisets.copyHighestCountFirst(
            covariance.getElementCooccurence().getColumnMultiset())
            .elementSet()) {
        if (topPatterns.size() > nTopPatterns) {
            break;
        }
        topPatterns.add(patternId);
    }

    printTopPatterns(topPatterns);

    printTopVectors(topImports, topPatterns);
}
项目:spinach    文件:GetJobsAction.java   
private void reconnectToNearestProducer(DisqueConnection<K, V> disqueConnection, boolean forcedReconnect) {
    log.debug("reconnectToNearestProducer()");
    Set<Multiset.Entry<String>> stats = Multisets.copyHighestCountFirst(nodePrefixes).entrySet();
    nodePrefixes.clear();

    if (!isNodeSwitchNecessary(stats) && !forcedReconnect) {
        return;
    }

    String nodeIdPrefix = getNodeIdPrefix(stats);
    if (nodeIdPrefix != null) {
        log.debug("Set preferred node prefix to {}", nodeIdPrefix);
        socketAddressSupplier.setPreferredNodeIdPrefix(nodeIdPrefix);
    }

    if (disqueConnection.isOpen()) {
        if (nodeIdPrefix == null) {
            log.info("Initiating reconnect");
        } else {
            log.info("Initiating reconnect to preferred node with prefix {}", nodeIdPrefix);
        }
        disconnect((RedisChannelHandler<?, ?>) disqueConnection);
    }
}
项目:naturalize    文件:AbstractIdentifierRenamings.java   
/**
 * @param relevantNgrams
 * @param currentName
 * @return
 */
public Multiset<String> getAlternativeNames(
        final Multiset<NGram<String>> relevantNgrams,
        final String currentName) {
    // Get all alternative namings
    final Multiset<String> nameAlternatives = ngramLM
            .getAlternativeNamings(relevantNgrams, WILDCARD_TOKEN);
    nameAlternatives.add(currentName); // Give the current identifier a
                                        // chance...

    // Prune naming alternatives
    final Multiset<String> toKeep = TreeMultiset.create();

    int seen = 0;
    for (final Entry<String> ent : Multisets.copyHighestCountFirst(
            nameAlternatives).entrySet()) {
        if (seen > 1000) {
            break;
        }
        toKeep.add(ent.getElement(), ent.getCount());
        seen++;
    }
    toKeep.add(AbstractNGramLM.UNK_SYMBOL);
    return toKeep;
}
项目:spring-usc    文件:ModelLearner_LOD_Greedy.java   
private List<Pattern> findMinimalCoveringSet(List<Pattern> sortedPatterns, List<String> types) {

        List<Pattern> minimalSet = new LinkedList<Pattern>();

        Multiset<String> sourceTypes = HashMultiset.create(types);
//      Multiset<String> coveredTypes = HashMultiset.create();

        for (Pattern p : sortedPatterns) {
            Multiset<String> patternTypes = HashMultiset.create(p.getTypes());
            Multiset<String> patternCommonTypes = Multisets.intersection(patternTypes, sourceTypes);
//          if (Multisets.containsOccurrences(coveredTypes, patternCommonTypes)) // this pattern does not cover any new source type
            if (patternCommonTypes.size() == 0) // this pattern does not cover any new source type
                continue;
            else {
                minimalSet.add(p);
//              coveredTypes.addAll(patternCommonTypes);
                Multisets.removeOccurrences(sourceTypes, patternCommonTypes);
            }
//          if (Multisets.containsOccurrences(coveredTypes, sourceTypes))
            if (sourceTypes.size() == 0)
                break;
        }
        return minimalSet;
    }
项目:easyccg    文件:Rebanker.java   
private void writeCatList(Multiset<Category> cats, File outputFile) throws IOException {
  Multiset<Category> catsNoPPorPRfeatures = HashMultiset.create();
  for (Category cat : cats) {
    catsNoPPorPRfeatures.add(cat.dropPPandPRfeatures());
  }
  FileWriter fw = new FileWriter(outputFile.getAbsoluteFile());
  BufferedWriter bw = new BufferedWriter(fw);


  int categories = 0;
  for (Category type : Multisets.copyHighestCountFirst(cats).elementSet()) {
    if (catsNoPPorPRfeatures.count(type.dropPPandPRfeatures()) >= 10) {
      bw.write(type.toString());
      bw.newLine();
      categories++;
    }
  }
  System.out.println("Number of cats occurring 10 times: " + categories);


  bw.flush();
  bw.close();


}
项目:bue-common-open    文件:ERECounter.java   
private static void trueMain(String[] argv) throws IOException {
  final File ereMap = new File(argv[0]);

  final ImmutableMap<Symbol, File> docIdToFileMap = FileUtils.loadSymbolToFileMap(ereMap);
  final ERELoader ereLoader = ERELoader.builder().build();

  final Multiset<String> eventMentionCountsByType = HashMultiset.create();

  for (final File ereFile : docIdToFileMap.values()) {
    for (final EREEvent docEvent : ereLoader.loadFrom(ereFile).getEvents()) {
      for (final EREEventMention eventMention : docEvent.getEventMentions()) {
        eventMentionCountsByType.add(eventMention.getType() + "." + eventMention.getSubtype());
      }
    }
  }

  log.info("ERE event mention counts by type:\n{}", StringUtils.unixNewlineJoiner().join(
      Multisets.copyHighestCountFirst(eventMentionCountsByType).entrySet()));
}
项目:guava    文件:MultisetEntrySetTester.java   
@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());
}
项目:guava    文件:MultisetNavigationTester.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  sortedMultiset = cast(getMultiset());
  entries =
      copyToList(
          getSubjectGenerator()
              .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
  Collections.sort(entries, sortedMultiset.comparator());

  // some tests assume SEVERAL == 3
  if (entries.size() >= 1) {
    a = Multisets.immutableEntry(entries.get(0), sortedMultiset.count(entries.get(0)));
    if (entries.size() >= 3) {
      b = Multisets.immutableEntry(entries.get(1), sortedMultiset.count(entries.get(1)));
      c = Multisets.immutableEntry(entries.get(2), sortedMultiset.count(entries.get(2)));
    }
  }
}
项目:guava    文件:MultisetEntrySetTester.java   
@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());
}
项目:guava    文件:MultisetNavigationTester.java   
@Override
public void setUp() throws Exception {
  super.setUp();
  sortedMultiset = cast(getMultiset());
  entries =
      copyToList(
          getSubjectGenerator()
              .getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
  Collections.sort(entries, sortedMultiset.comparator());

  // some tests assume SEVERAL == 3
  if (entries.size() >= 1) {
    a = Multisets.immutableEntry(entries.get(0), sortedMultiset.count(entries.get(0)));
    if (entries.size() >= 3) {
      b = Multisets.immutableEntry(entries.get(1), sortedMultiset.count(entries.get(1)));
      c = Multisets.immutableEntry(entries.get(2), sortedMultiset.count(entries.get(2)));
    }
  }
}
项目:Cauldron    文件:Loader.java   
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);
    }
}
项目:Cauldron    文件:Loader.java   
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);
    }
}
项目:Cauldron    文件:Loader.java   
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);
    }
}
项目:RuneCraftery    文件:Loader.java   
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);
    }
}
项目:RuneCraftery    文件:Loader.java   
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);
    }
}
项目:BetterNutritionMod    文件:Loader.java   
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);
    }
}
项目:internet-impression-visualizer    文件:WordCloud.java   
public List<String> getMostFrequentWordsList() {
    List<String> mostFrequentWords = new ArrayList<String>(20);
    int counter = 0;
    for (String word : Multisets.copyHighestCountFirst(wordCloud)
            .elementSet()) {
        mostFrequentWords.add(word);
        // INFO: This looks a little ugly, but actually allows us all the
        // benefits of using an iterator along with allowing rare case of
        // lists smaller than 20 words to be returned.
        counter++;
        if (counter >= 20) {
            break;
        }

    }

    return mostFrequentWords;
}
项目:PaleoMachineFramework    文件:MultiInput.java   
private boolean compareInputs(boolean shapeless, RecipeItemStack[] inputs1,
        RecipeItemStack[] inputs2) {
    boolean valid = false;
    if (shapeless) {
        Multiset<RecipeItemStack> set1 = HashMultiset.create(Arrays
                .asList(inputs1));
        Multiset<RecipeItemStack> set2 = HashMultiset.create(Arrays
                .asList(inputs2));

        return Multisets.containsOccurrences(set2, set1);
    } else {
        for (int i = 0; i < inputs1.length; i++) {
            if (inputs1[i].equals(inputs2[i]))
                valid = true;
            else
                break;
        }
    }
    return valid;
}
项目:Fuelsmod    文件:MultiInput.java   
private boolean compareInputs(boolean shapeless, RecipeItemStack[] inputs1,
        RecipeItemStack[] inputs2) {
    boolean valid = false;
    if (shapeless) {
        Multiset<RecipeItemStack> set1 = HashMultiset.create(Arrays
                .asList(inputs1));
        Multiset<RecipeItemStack> set2 = HashMultiset.create(Arrays
                .asList(inputs2));

        return Multisets.containsOccurrences(set2, set1);
    } else {
        for (int i = 0; i < inputs1.length; i++) {
            if (inputs1[i].equals(inputs2[i]))
                valid = true;
            else
                break;
        }
    }
    return valid;
}
项目:levelup-java-exercises    文件:SlotMachineSimulation.java   
/**
 * 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;
}
项目:tac-kbp-eal    文件:GoldArgumentCountsInspector.java   
static void writeTsv(ImmutableMultiset<String> data, File file) throws IOException {
  try (Writer out = Files.asCharSink(file, Charsets.UTF_8).openBufferedStream()) {
    for (Entry<String> e : Multisets.copyHighestCountFirst(data).entrySet()) {
      out.write(e.getElement() + "\t" + e.getCount() + "\n");
    }
  }
}
项目:tac-kbp-eal    文件:BootstrappedPerEventResultWriter.java   
@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));
  }
}
项目:guava-mock    文件:MultisetForEachEntryTester.java   
public void testForEachEntry() {
  List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
  List<Entry<E>> actual = new ArrayList<>();
  getMultiset()
      .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
  Helpers.assertEqualIgnoringOrder(expected, actual);
}
项目:guava-mock    文件:MultisetForEachEntryTester.java   
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachEntryOrdered() {
  List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
  List<Entry<E>> actual = new ArrayList<>();
  getMultiset()
      .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
  assertEquals(expected, actual);
}
项目:guava-mock    文件:MultisetForEachEntryTester.java   
public void testForEachEntryDuplicates() {
  initThreeCopies();
  List<Entry<E>> expected = Collections.singletonList(Multisets.immutableEntry(e0(), 3));
  List<Entry<E>> actual = new ArrayList<>();
  getMultiset()
      .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
  assertEquals(expected, actual);
}
项目:guava-mock    文件:MultisetEntrySetTester.java   
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testEntrySet_removePresent() {
  assertTrue(
      "multiset.entrySet.remove(presentEntry) returned false",
      getMultiset().entrySet().remove(Multisets.immutableEntry(e0(), 1)));
  assertFalse("multiset contains element after removing its entry", getMultiset().contains(e0()));
}