Example usage for com.google.common.collect Multiset add

List of usage examples for com.google.common.collect Multiset add

Introduction

In this page you can find the example usage for com.google.common.collect Multiset add.

Prototype

@Override
boolean add(E element);

Source Link

Document

Adds a single occurrence of the specified element to this multiset.

Usage

From source file:com.github.tomakehurst.wiremock.recording.SnapshotStubMappingPostProcessor.java

public List<StubMapping> process(Iterable<StubMapping> stubMappings) {
    final Multiset<RequestPattern> requestCounts = HashMultiset.create();
    final List<StubMapping> processedStubMappings = new ArrayList<>();

    for (StubMapping stubMapping : stubMappings) {
        requestCounts.add(stubMapping.getRequest());

        // Skip duplicate requests if shouldRecordRepeatsAsScenarios is not enabled
        if (requestCounts.count(stubMapping.getRequest()) > 1 && !shouldRecordRepeatsAsScenarios) {
            continue;
        }/*from  w w w  .ja  va 2  s .  c o m*/

        if (bodyExtractMatcher != null && bodyExtractMatcher.match(stubMapping.getResponse()).isExactMatch()) {
            bodyExtractor.extractInPlace(stubMapping);
        }

        processedStubMappings.add(stubMapping);
    }

    if (shouldRecordRepeatsAsScenarios) {
        new ScenarioProcessor().putRepeatedRequestsInScenarios(processedStubMappings);
    }

    // Run any stub mapping transformer extensions
    return Lists.transform(processedStubMappings, transformerRunner);
}

From source file:additionalpipes.chunk.ChunkManager.java

public void toggleLasers(EntityPlayerMP player, boolean showAllPersistentChunks) {
    if (!players.containsKey(player)) {
        Multiset<ChunkCoordIntPair> newSet = HashMultiset.create();
        if (showAllPersistentChunks) {
            newSet.add(null);
        }/*  w  ww. j a  v  a2  s  .c om*/
        players.put(player, newSet);
        sendPersistentChunks(player);
    } else {
        hideLasers(player);
    }
}

From source file:br.com.caelum.vraptor.observer.upload.CommonsUploadMultipartObserver.java

protected String fixIndexedParameters(String name, Multiset<String> indexes) {
    if (name.contains("[]")) {
        String newName = name.replace("[]", "[" + (indexes.count(name)) + "]");
        indexes.add(name);
        logger.debug("{} was renamed to {}", name, newName);

        return newName;
    }//from w  w w  .  j ava2  s . com
    return name;
}

From source file:uk.ac.ebi.intact.editor.services.admin.report.AssignmentReportService.java

@Transactional(value = "jamiTransactionManager", propagation = Propagation.REQUIRED, readOnly = true)
public List<AssignmentInfo> calculatePublicationReviewerAssignments(Date fromDate, Date toDate) {
    List<AssignmentInfo> assignmentInfos = new ArrayList<AssignmentInfo>();

    Query query = getIntactDao().getEntityManager()
            .createQuery("select distinct p from IntactPublication p join p.lifecycleEvents as e where "
                    + "e.cvEvent.shortName = :cvEvent and e.when >= :dateFrom and e.when <= :dateTo and e.note is null");
    query.setParameter("cvEvent", LifeCycleEventType.READY_FOR_CHECKING.shortLabel());
    query.setParameter("dateFrom", fromDate);
    query.setParameter("dateTo", new DateTime(toDate).plusDays(1).minusSeconds(1).toDate());

    List<IntactPublication> pubs = query.getResultList();

    Multiset<String> multiset = HashMultiset.create();

    for (IntactPublication pub : pubs) {
        for (LifeCycleEvent event : pub.getLifecycleEvents()) {
            multiset.add(pub.getCurrentReviewer().getLogin());
        }/*from  w ww  .ja v  a  2  s .c o  m*/
    }

    int total = multiset.size();

    for (String reviewer : multiset.elementSet()) {
        int count = multiset.count(reviewer);
        int percentage = count * 100 / total;
        assignmentInfos.add(new AssignmentInfo(reviewer, count, percentage));
    }

    return assignmentInfos;
}

From source file:uk.ac.ebi.intact.editor.services.admin.report.AssignmentReportService.java

@Transactional(value = "jamiTransactionManager", propagation = Propagation.REQUIRED, readOnly = true)
public List<AssignmentInfo> calculateComplexReviewerAssignments(Date fromDate, Date toDate) {
    List<AssignmentInfo> assignmentInfos = new ArrayList<AssignmentInfo>();

    Query query = getIntactDao().getEntityManager()
            .createQuery("select distinct c from IntactComplex c join c.lifecycleEvents as e where "
                    + "e.cvEvent.shortName = :cvEvent and e.when >= :dateFrom and e.when <= :dateTo and e.note is null");
    query.setParameter("cvEvent", LifeCycleEventType.READY_FOR_CHECKING.shortLabel());
    query.setParameter("dateFrom", fromDate);
    query.setParameter("dateTo", new DateTime(toDate).plusDays(1).minusSeconds(1).toDate());

    List<IntactComplex> complexes = query.getResultList();

    Multiset<String> multiset = HashMultiset.create();

    for (IntactComplex pub : complexes) {
        for (LifeCycleEvent event : pub.getLifecycleEvents()) {
            multiset.add(pub.getCurrentReviewer().getLogin());
        }//from   w ww.j  a  va 2 s .c  o  m
    }

    int total = multiset.size();

    for (String reviewer : multiset.elementSet()) {
        int count = multiset.count(reviewer);
        int percentage = count * 100 / total;
        assignmentInfos.add(new AssignmentInfo(reviewer, count, percentage));
    }

    return assignmentInfos;
}

From source file:org.dllearner.utilities.examples.AutomaticNegativeExampleFinderSPARQL2.java

public SortedSet<OWLIndividual> getNegativeExamples(OWLClass classToDescribe,
        Set<OWLIndividual> positiveExamples, Map<Strategy, Double> strategiesWithWeight,
        int maxNrOfReturnedInstances) {
    //set class to describe as the type for each instance
    Multiset<OWLClass> types = HashMultiset.create();
    types.add(classToDescribe);

    return computeNegativeExamples(classToDescribe, types, strategiesWithWeight, maxNrOfReturnedInstances);
}

From source file:net.timendum.pdf.StatisticParser.java

private void incrementOrAdd(Multiset<Float> multiset, float key) {
    multiset.add(key);
}

From source file:gr.forth.ics.swkm.model2.util.NamespaceDependenciesIndex.java

private void addDependency(Uri uri1, Uri uri2, Direction direction) {
    Map<Uri, Multiset<Uri>> deps = deps(direction);
    Multiset<Uri> depsOfNamespace = depsPerNamespace(deps, uri1);
    depsOfNamespace.add(uri2);
}

From source file:org.caleydo.view.domino.internal.data.Categorical2DDataDomainValues.java

/**
 * @param t2/*from w  w  w  .  java2  s  .c om*/
 * @return
 */
private Pair<TypedGroupSet, TypedGroupSet> extractGroups(TablePerspective t) {
    Multimap<Object, Integer> dimGroups = HashMultimap.create();
    Multimap<Object, Integer> recGroups = HashMultimap.create();

    TypedSet d = TypedSet.of(t.getDimensionPerspective().getVirtualArray());
    TypedSet r = TypedSet.of(t.getRecordPerspective().getVirtualArray());
    List<Multiset<Object>> rows = new ArrayList<>(r.size());
    for (int i = 0; i < r.size(); ++i)
        rows.add(HashMultiset.create());

    for (Integer dim : d) {
        Multiset<Object> col = HashMultiset.create();

        int i = 0;
        for (Integer rec : r) {
            Object v = getRaw(dim, rec);
            col.add(v);
            rows.get(i++).add(v);
        }

        Object mostFrequent = mostFrequent(col);
        dimGroups.put(mostFrequent, dim);
    }

    {
        int i = 0;
        for (Integer rec : r) {
            Multiset<Object> row = rows.get(i++);

            Object mostFrequent = mostFrequent(row);
            recGroups.put(mostFrequent, rec);
        }
    }

    List<CategoryProperty<?>> categories = getCategories(getDataDomain());
    return Pair.make(toGroups(dimGroups, categories, d.getIdType()),
            toGroups(recGroups, categories, r.getIdType()));
}

From source file:edu.berkeley.compbio.ml.MultiClassCrossValidationResults.java

public void addSample(final L realValue, final L predictedValue) {
    final Multiset<L> confusionRow = realValue == null ? confusionRowNull : confusionMatrix.get(realValue);
    confusionRow.add(predictedValue);
    numExamples++;/*from  www .  ja v  a 2 s  . c  o  m*/
}