Example usage for com.google.common.collect Multimap get

List of usage examples for com.google.common.collect Multimap get

Introduction

In this page you can find the example usage for com.google.common.collect Multimap get.

Prototype

Collection<V> get(@Nullable K key);

Source Link

Document

Returns a view collection of the values associated with key in this multimap, if any.

Usage

From source file:org.sosy_lab.cpachecker.pcc.strategy.partitioning.PartitionChecker.java

public static boolean areElementsCoveredByPartitionElement(final Collection<AbstractState> pInOtherPartitions,
        Multimap<CFANode, AbstractState> pInPartition, final StopOperator pStop, final Precision pPrec)
        throws CPAException, InterruptedException {
    HashSet<AbstractState> partitionNodes = new HashSet<>(pInPartition.values());

    for (AbstractState outState : pInOtherPartitions) {
        if (!partitionNodes.contains(outState)
                && !pStop.stop(outState, pInPartition.get(AbstractStates.extractLocation(outState)), pPrec)) {
            return false;
        }/*from   ww w .  j  a v  a 2 s . c  o m*/
    }

    return true;
}

From source file:moavns.SolucaoAleatoria.java

public static Solucao eliminarRedundancia(Solucao solucao) {
    Multimap<Float, Integer> colunas = TreeMultimap.create();
    for (Coluna coluna : solucao.getColunas()) {
        Float custo = coluna.getCusto();
        colunas.put((custo * (-1)), coluna.getNome());
    }// w  w  w  .  j ava  2s .c o  m
    Solucao testarsolucao = new Solucao(solucao);
    for (Float chave : colunas.keySet()) {
        Iterator iterador = colunas.get(chave).iterator();
        while (iterador.hasNext()) {
            Solucao testar = new Solucao(testarsolucao);
            Coluna maiorcoluna = testarsolucao.getLinhasX().get(iterador.next());
            testar.getLinhasCobertas().clear();
            cobrirLinhas(maiorcoluna, testar);
            if (testar.getLinhasCobertas().size() == testar.getQtdeLinhas()) {
                testar.getColunas().remove(maiorcoluna);
                testar.setCustototal(testar.getCustototal() - maiorcoluna.getCusto());
                testarsolucao = testar;
            }
        }
    }
    return testarsolucao;
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.xmi.exporter.ecore.EntityClassStore.java

public static List<EObject> getCoreEntities(Collection<EObject> eObjects) {
    Multimap<Class<? extends IdEntity>, EObject> orderedObjects = groupEObjects(eObjects);

    LinkedList<EObject> objects = Lists.newLinkedList();
    for (Class<? extends IdEntity> class1 : getCoreClasses()) {
        objects.addAll(orderedObjects.get(class1));
    }/* w  w w . j  av a 2 s  .com*/

    return objects;
}

From source file:jatf.common.util.ArchitectureTestUtil.java

@Nonnull
public static Set<String> getAllClassesInReflections(Reflections reflections) {
    Set<String> result = newHashSet();
    for (String key : reflections.getStore().keySet()) {
        Multimap<String, String> multimap = reflections.getStore().get(key);
        for (String name : multimap.keySet()) {
            Collection<String> collection = multimap.get(name);
            result.addAll(collection.stream().filter(item -> startsWithAnyOf(SCOPES, item))
                    .collect(Collectors.toList()));
        }//from  w w  w  . j ava 2  s.  co  m
    }
    return result;
}

From source file:com.zxy.commons.poi.excel.ExcelUtils.java

/**
 * multimap?table/*from w  w  w  . ja va2s.  c om*/
 * 
 * @param multimap multimap
 * @return table
*/
public static Table<Integer, String, String> map2table(Multimap<String, String> multimap) {
    Table<Integer, String, String> table = TreeBasedTable.create();
    Set<String> cloumns = multimap.keySet();
    for (String cloumn : cloumns) {
        Collection<String> values = multimap.get(cloumn);
        int rowIndex = 1;
        for (String value : values) {
            table.put(rowIndex, cloumn, value);
            rowIndex++;
        }
    }
    return table;
}

From source file:io.covert.dns.storage.accumulo.mutgen.EdgeMutationGeneratorFactory.java

public static void configure(Job job, String table, String dataType, boolean bidirectional,
        boolean univariateStats, Multimap<String, String> edges) {
    Configuration conf = job.getConfiguration();

    conf.set("edge.mutation.generator.table", table);
    conf.set("edge.mutation.generator.data.type", dataType);

    conf.setBoolean("edge.mutation.generator.bidirection", bidirectional);
    conf.setBoolean("edge.mutation.generator.univar.stats", univariateStats);

    StringBuilder s = new StringBuilder();
    boolean first = true;
    for (String name1 : edges.keySet()) {
        for (String name2 : edges.get(name1)) {
            if (first) {
                first = false;//w  w w  . j av  a  2s . co m
                s.append(name1).append(":").append(name2);
            } else {
                s.append(",").append(name1).append(":").append(name2);
            }
        }
    }
    conf.set("edge.mutation.generator.edges", s.toString());
}

From source file:grakn.core.graql.reasoner.rule.RuleUtils.java

/**
 * @param rules to be stratified (ordered)
 * @return stream of rules ordered in terms of priority (high priority first)
 *///from  w w  w  .  j a  v  a 2 s.co  m
public static Stream<InferenceRule> stratifyRules(Set<InferenceRule> rules) {
    if (rules.stream().allMatch(r -> r.getBody().isPositive())) {
        return rules.stream().sorted(Comparator.comparing(r -> -r.resolutionPriority()));
    }
    Multimap<Type, InferenceRule> typeMap = HashMultimap.create();
    rules.forEach(r -> r.getRule().thenTypes().flatMap(Type::sups).forEach(t -> typeMap.put(t, r)));
    HashMultimap<Type, Type> typeGraph = persistedTypeSubGraph(rules);
    List<Set<Type>> scc = new TarjanSCC<>(typeGraph).getSCC();
    return Lists.reverse(scc).stream().flatMap(strata -> strata.stream().flatMap(t -> typeMap.get(t).stream())
            .sorted(Comparator.comparing(r -> -r.resolutionPriority())));
}

From source file:nova.core.wrapper.mc.forge.v18.asm.lib.ASMHelper.java

public static byte[] injectMethods(String name, byte[] bytes, Multimap<String, MethodInjector> injectors) {
    if (injectors.containsKey(name)) {
        ClassNode cnode = createClassNode(bytes);

        for (MethodInjector injector : injectors.get(name)) {
            MethodNode method = findMethod(injector.method, cnode);
            if (method == null) {
                throw new RuntimeException("Method not found: " + injector.method);
            }//from  ww w. j  a v  a 2  s.c  o m
            System.out.println("Injecting into " + injector.method + "\n" + printInsnList(injector.injection));

            List<AbstractInsnNode> callNodes;
            if (injector.before) {
                callNodes = InstructionComparator.insnListFindStart(method.instructions, injector.needle);
            } else {
                callNodes = InstructionComparator.insnListFindEnd(method.instructions, injector.needle);
            }

            if (callNodes.size() == 0) {
                throw new RuntimeException("Needle not found in Haystack: " + injector.method + "\n"
                        + printInsnList(injector.needle));
            }

            for (AbstractInsnNode node : callNodes) {
                if (injector.before) {
                    System.out.println("Injected before: " + printInsn(node));
                    method.instructions.insertBefore(node, cloneInsnList(injector.injection));
                } else {
                    System.out.println("Injected after: " + printInsn(node));
                    method.instructions.insert(node, cloneInsnList(injector.injection));
                }
            }
        }

        bytes = createBytes(cnode, ClassWriter.COMPUTE_FRAMES);
    }
    return bytes;
}

From source file:de.iteratec.iteraplan.elasticeam.derived.DerivedMetamodelFactory.java

private static Multimap<Integer, List<RelationshipEndExpression>> collectPathCandidates(
        SubstantialTypeExpression startClass, int length) {
    Multimap<Integer, List<RelationshipEndExpression>> pathsAndPrefixes = HashMultimap.create();
    for (RelationshipEndExpression relationshipEnd : startClass.getRelationshipEnds()) {
        pathsAndPrefixes.putAll(Integer.valueOf(2),
                expandByOneStep(Collections.singletonList(relationshipEnd)));
    }//from  www. j  av  a  2s. c  o  m
    for (int i = 3; i <= length; i++) {
        for (List<RelationshipEndExpression> prefix : pathsAndPrefixes.get(Integer.valueOf(i - 1))) {
            pathsAndPrefixes.putAll(Integer.valueOf(i), expandByOneStep(prefix));
        }
    }
    return pathsAndPrefixes;
}

From source file:com.palantir.atlasdb.keyvalue.impl.ProfilingKeyValueService.java

private static <T> long byteSize(Multimap<Cell, T> values) {
    long sizeInBytes = 0;
    for (Cell cell : values.keySet()) {
        sizeInBytes += Cells.getApproxSizeOfCell(cell) + values.get(cell).size();
    }//from ww  w  .j a  v a  2s . co m
    return sizeInBytes;
}