Example usage for java.util LinkedHashMap entrySet

List of usage examples for java.util LinkedHashMap entrySet

Introduction

In this page you can find the example usage for java.util LinkedHashMap entrySet.

Prototype

public Set<Map.Entry<K, V>> entrySet() 

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:com.alibaba.wasp.plan.parser.druid.DruidDDLParser.java

public int getIndex(String name, LinkedHashMap<String, Field> columns) throws UnsupportedException {
    Iterator<Entry<String, Field>> iter = columns.entrySet().iterator();
    int i = 0;//from   ww w . ja v  a2 s.co m
    while (iter.hasNext()) {
        Field field = iter.next().getValue();
        if (field.getName().equals(name)) {
            return i;
        }
        i++;
    }
    throw new UnsupportedException(name + " is not in set");
}

From source file:com.mercatis.lighthouse3.commons.commons.XmlMuncher.java

/**
 * This method produces sub munchers out of the current XML muncher limited
 * to a certain context. This allows one to query repeating complex element
 * structures./* w w  w.  j  av  a2s  . co  m*/
 *
 * @param xpathExpression the XPath expression defining the context.
 * @return a list of new munchers.
 * @throws XPathExpressionException in case the XPath expression is invalid.
 */
public List<XmlMuncher> getSubMunchersForContext(String xpathExpression) throws DOMException {
    List<XmlMuncher> subMunchers = new ArrayList<XmlMuncher>();
    XmlMuncher currentMuncher = new XmlMuncher();

    Pattern translation = null;
    try {
        translation = this.translateXPathExpressionToRegexp(xpathExpression);
    } catch (XPathExpressionException e) {
        throw new DOMException((short) 0, "Could not evaluate XPathExpression: " + e.getMessage());
    }

    for (LinkedHashMap<String, String> currentPathBatch : this.documentPaths) {
        Iterator<Entry<String, String>> currentPaths = currentPathBatch.entrySet().iterator();
        ;

        while (currentPaths.hasNext()) {
            Entry<String, String> currentPath = currentPaths.next();

            String localizedPath = this.localizePath(translation, currentPath.getKey());

            if (localizedPath != null && !localizedPath.substring(1).contains("/")) {
                if (!currentMuncher.isEmpty()) {
                    subMunchers.add(currentMuncher);
                    currentMuncher = new XmlMuncher();
                }
            } else if (localizedPath != null) {
                currentMuncher.addDocumentPath(currentMuncher.documentPaths, localizedPath,
                        currentPath.getValue());
            }
        }

    }

    if (!currentMuncher.isEmpty()) {
        subMunchers.add(currentMuncher);
    }

    return subMunchers;
}

From source file:gov.llnl.lc.smt.command.link.SmtLink.java

private int getNumLevels(LinkedHashMap<String, IB_Edge> eMap) {
    // given a map of edges, find the maximum depth, it must be the number of levels
    int maxLevel = 0;

    for (Entry<String, IB_Edge> entry : eMap.entrySet()) {
        IB_Edge e = entry.getValue();//  ww w .j av a2 s.c  om
        maxLevel = maxLevel > e.getDepth() ? maxLevel : e.getDepth();
    }
    return maxLevel + 1;
}

From source file:com.github.gfx.android.orma.migration.SchemaDiffMigration.java

/**
 * @param srcIndexes Set of "CREATE INDEX" statements which the DB has
 * @param dstIndexes Set of "CREATE INDEX" statements which the running code has
 * @return List of "CREATED INDEX" statements to apply to DB
 *///from w  ww .  ja v  a  2 s  . c  om
@NonNull
public List<String> indexDiff(@NonNull Collection<String> srcIndexes, @NonNull Collection<String> dstIndexes) {
    LinkedHashMap<CreateIndexStatement, String> unionIndexes = new LinkedHashMap<>();

    Map<CreateIndexStatement, String> srcIndexesPairs = parseIndexes(srcIndexes);
    unionIndexes.putAll(srcIndexesPairs);

    Map<CreateIndexStatement, String> dstIndexesPairs = parseIndexes(dstIndexes);
    unionIndexes.putAll(dstIndexesPairs);

    List<String> createIndexStatements = new ArrayList<>();
    for (Map.Entry<CreateIndexStatement, String> createIndexStatement : unionIndexes.entrySet()) {
        boolean existsInDst = dstIndexesPairs.containsKey(createIndexStatement.getKey());
        boolean existsInSrc = srcIndexesPairs.containsKey(createIndexStatement.getKey());

        if (existsInDst && existsInSrc) {
            // okay, nothing to do
        } else if (existsInDst) {
            createIndexStatements.add(createIndexStatement.getValue());
        } else { // existsInSrc
            createIndexStatements.add(buildDropIndexStatement(createIndexStatement.getKey()));
        }
    }
    return createIndexStatements;
}

From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java

private Iterator<Map.Entry<Number, Object>> iterateThrough(final LinkedHashMap<Number, Object> expected) {
    Iterator<Map.Entry<Number, Object>> iter = expected.entrySet().iterator();
    for (int i = 0; i < expected.size(); i++) {
        iter.next();//from w  ww.  java  2s  . c o  m
    }
    return iter;
}

From source file:gov.llnl.lc.smt.command.link.SmtLink.java

private boolean printStringMap(LinkedHashMap<String, String> map) {
    // the tops are all calculated, find the links associated with these
    // ports/*from   ww  w  .j a  v  a 2s  . co  m*/
    // and return the top unique links

    for (Map.Entry<String, String> mapEntry : map.entrySet()) {
        String s = mapEntry.getValue();
        System.out.println(s);
    }
    return true;
}

From source file:gov.llnl.lc.smt.command.fabric.SmtFabric.java

private void showDiscoveredFabrics(Map<String, String> map) {
    String hostNam = map.get(SmtProperty.SMT_HOST.getName());
    String portNum = map.get(SmtProperty.SMT_PORT.getName());
    String numPorts = map.get(SmtProperty.SMT_FABRIC_DISCOVER.getName());

    // this will do the actual discovery
    LinkedHashMap<String, OpenSmMonitorService> omsFabrics = OpenSmMonitorService
            .discoverOpenSmMonitorService(hostNam, portNum, numPorts);

    OpenSmMonitorService OMS = null;/*ww  w  . j  a v a  2  s  . co  m*/
    String portString = null;

    for (Map.Entry<String, OpenSmMonitorService> entry : omsFabrics.entrySet()) {
        OMS = entry.getValue();
        portString = entry.getKey();

        if (OMS != null) {
            logger.info("The OMS timestamp is: " + OMS.getTimeStamp());
            StringBuffer s = new StringBuffer();
            s.append("OMS port    :   " + portString + SystemConstants.NEW_LINE);
            s.append("Fabric name :   " + OMS.getFabricName() + SystemConstants.NEW_LINE);
            s.append(SystemConstants.NEW_LINE);

            s.append(new SmtFabricStructure(OMS).toString());
            s.append("/***************************************************/");
            System.out.println(s.toString());
        }
    }
}

From source file:rb.app.RBSCMSystem.java

/**
* Private helper function to sort the indices of C_J
* based on distance from current_parameters
*//* w  w  w.j  a v a2 s  .com*/
private List<Integer> getSorted_CJ_Indices() {

    int J = C_J.size();

    LinkedHashMap<Double, Integer> dist_from_mu = new LinkedHashMap<Double, Integer>(J);

    for (int j = 0; j < J; j++) {
        double dist = param_dist(get_current_parameters(), C_J.get(j));
        dist_from_mu.put(dist, j);
    }

    List<Map.Entry<Double, Integer>> list = new LinkedList<Map.Entry<Double, Integer>>(dist_from_mu.entrySet());
    Collections.sort(list, new Comparator() {
        public int compare(Object o1, Object o2) {
            return ((Comparable) ((Map.Entry) (o1)).getKey()).compareTo(((Map.Entry) (o2)).getKey());
        }
    });

    // Create a sorted list of values to return
    List<Integer> result = new LinkedList<Integer>();
    for (Iterator it = list.iterator(); it.hasNext();) {
        Map.Entry<Double, Integer> entry = (Map.Entry<Double, Integer>) it.next();
        result.add(entry.getValue());
    }

    return result;
}

From source file:org.apache.hive.ptest.execution.conf.UnitTestPropertiesParser.java

private Collection<TestBatch> createTestBatches(LinkedHashMap<String, LinkedHashSet<TestInfo>> allTests,
        RootConfig rootConfig, Map<String, ModuleConfig> moduleConfigs) {
    List<TestBatch> testBatches = new LinkedList<>();
    for (Map.Entry<String, LinkedHashSet<TestInfo>> entry : allTests.entrySet()) {
        logger.info("Creating test batches for module={}, numTests={}", entry.getKey(),
                entry.getValue().size());
        String currentModule = entry.getKey();
        String currentPathPrefix = getPathPrefixFromModuleName(currentModule);
        int batchSize = rootConfig.batchSize;
        if (moduleConfigs.containsKey(currentModule)) {
            ModuleConfig moduleConfig = moduleConfigs.get(currentModule);
            int batchSizeModule = moduleConfig.batchSize;
            if (batchSizeModule != DEFAULT_PROP_BATCH_SIZE_NOT_SPECIFIED) {
                batchSize = batchSizeModule;
            }//from  w  w w  .  j a  va  2 s. c o m
        }

        if (batchSize == DEFAULT_PROP_BATCH_SIZE_INCLUDE_ALL) {
            batchSize = Integer.MAX_VALUE;
        }
        logger.info("batchSize determined to be {} for module={}", batchSize, currentModule);

        // TODO Even out the batch sizes (i.e. 20/20/1 should be replaced by 14/14/13)
        List<String> currentList = new LinkedList<>();
        for (TestInfo testInfo : entry.getValue()) {
            if (testInfo.isIsolated || testInfo.skipBatching) {
                UnitTestBatch unitTestBatch = new UnitTestBatch(batchIdCounter, testCasePropertyName,
                        Collections.singletonList(testInfo.testName), currentPathPrefix, !testInfo.isIsolated);
                testBatches.add(unitTestBatch);
            } else {
                currentList.add(testInfo.testName);
                if (currentList.size() == batchSize) {
                    UnitTestBatch unitTestBatch = new UnitTestBatch(batchIdCounter, testCasePropertyName,
                            Collections.unmodifiableList(currentList), currentPathPrefix, true);
                    testBatches.add(unitTestBatch);
                    currentList = new LinkedList<>();
                }
            }
        }
        if (!currentList.isEmpty()) {
            UnitTestBatch unitTestBatch = new UnitTestBatch(batchIdCounter, testCasePropertyName,
                    Collections.unmodifiableList(currentList), currentPathPrefix, true);
            testBatches.add(unitTestBatch);
        }
    }
    return testBatches;
}

From source file:com.google.gwt.emultest.java.util.LinkedHashMapTest.java

public void testEntrySetRemove() {
    LinkedHashMap<String, String> hashMap = new LinkedHashMap<String, String>();
    hashMap.put("A", "B");
    LinkedHashMap<String, String> dummy = new LinkedHashMap<String, String>();
    dummy.put("A", "b");
    Entry<String, String> bogus = dummy.entrySet().iterator().next();
    Set<Entry<String, String>> entrySet = hashMap.entrySet();
    boolean removed = entrySet.remove(bogus);
    assertEquals(removed, false);//from   w  w  w. ja v a2s .c o m
    assertEquals(hashMap.get("A"), "B");
}