Example usage for java.util TreeMap keySet

List of usage examples for java.util TreeMap keySet

Introduction

In this page you can find the example usage for java.util TreeMap keySet.

Prototype

public Set<K> keySet() 

Source Link

Document

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

Usage

From source file:io.mapzone.arena.analytics.graph.ui.FeaturePropertySelectorUI.java

private void fill() {
    if (combo != null && !combo.isDisposed() && featureSource != null) {

        final Collection<PropertyDescriptor> schemaDescriptors = featureSource.getSchema().getDescriptors();
        final GeometryDescriptor geometryDescriptor = featureSource.getSchema().getGeometryDescriptor();
        final TreeMap<String, PropertyDescriptor> properties = Maps.newTreeMap();
        for (PropertyDescriptor descriptor : schemaDescriptors) {
            if (geometryDescriptor == null || !geometryDescriptor.equals(descriptor)) {
                properties.put(descriptor.getName().getLocalPart(), descriptor);
            }/*w  ww.  j  a  v  a 2 s .c  o m*/
        }
        final List<String> columns = Lists.newArrayList();
        columns.addAll(properties.keySet());
        combo.setItems(columns.toArray(new String[properties.size()]));

        combo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                onSelect.accept(properties.get(columns.get(combo.getSelectionIndex())));
            }
        });
        combo.getParent().layout();
    }
}

From source file:ubic.gemma.model.association.coexpression.GeneCoexpressionNodeDegreeValueObject.java

private double[] asDoubleArray(TreeMap<Integer, Double> map) {
    DoubleArrayList list = new DoubleArrayList();
    if (map.isEmpty())
        return this.toPrimitive(list);
    list.setSize(Math.max(list.size(), map.lastKey() + 1));
    for (Integer s : map.keySet()) {
        list.set(s, map.get(s));/*w  w w . j  a  va 2 s  .com*/
    }

    return this.toPrimitive(list);
}

From source file:org.apache.hadoop.hive.ql.exec.ComputationBalancerReducer.java

void flushTableStatsInfo(FSDataOutputStream out) throws Exception {
    out.writeBytes("TableInformation\n");
    out.writeBytes("stat_num_records" + ToolBox.hiveDelimiter + stat_num_records + "\n");
    ArrayList<TreeMap<String, Integer>> _a = ToolBox.<Integer>aggregateKey(infoDict, ToolBox.hiveDelimiter, 2);

    LOG.debug("stat_num_records:  " + stat_num_records);

    for (TreeMap<String, Integer> treeMap : _a) {
        if (treeMap == null)
            continue;
        for (String _s : treeMap.keySet()) {
            out.writeBytes(_s + ToolBox.hiveDelimiter + treeMap.get(_s) + "\n");
            LOG.debug(_s + ToolBox.hiveDelimiter + treeMap.get(_s));
            if (_s.startsWith(StatsCollectionOperator.FIELDLENGTH_ATTR)) {
                double _tmp = (double) treeMap.get(_s) / (double) stat_num_records;
                String _avg = StatsCollectionOperator.AVGFIELDWIDTH
                        + _s.substring(StatsCollectionOperator.FIELDLENGTH_ATTR.length());
                out.writeBytes(_avg + ToolBox.hiveDelimiter + (long) _tmp + "\n");
            }/*from   w  w  w  .  j a  v a 2s.c  o m*/

            if (_s.startsWith(StatsCollectionOperator.NULLCOUNTER_ATTR)) {
                double _tmp = (double) treeMap.get(_s) / (double) stat_num_records;
                String _avg = StatsCollectionOperator.NULLFAC_ATTR
                        + _s.substring(StatsCollectionOperator.NULLCOUNTER_ATTR.length());
                out.writeBytes(_avg + ToolBox.hiveDelimiter + _tmp + "\n");
            }
        }
    }
}

From source file:mrmc.chart.ROCCurvePlot.java

/**
 * Converts the mapping of readers to curve points into a collection of
 * separate XY data.//from   www  .  ja v a 2 s  . c  om
 * 
 * @param treeMap Mapping of readers to points defining a curve
 */
private void createDataset(TreeMap<String, TreeSet<XYPair>> treeMap) {
    seriesCollection = new XYSeriesCollection();
    readerSeriesTitles = new ArrayList<String>();

    for (String r : treeMap.keySet()) {
        XYSeries series = new XYSeries("" + r, false);
        readerSeriesTitles.add("" + r);
        for (XYPair point : treeMap.get(r)) {
            series.add(point.x, point.y);
        }
        seriesCollection.addSeries(series);
    }

    allLines = new ArrayList<InterpolatedLine>();
    for (String r : treeMap.keySet()) {
        allLines.add(new InterpolatedLine(treeMap.get(r)));
    }

    XYSeries vertAvg = generateVerticalROC();
    seriesCollection.addSeries(vertAvg);
    XYSeries horizAvg = generateHorizontalROC();
    seriesCollection.addSeries(horizAvg);
    XYSeries diagAvg = generateDiagonalROC(treeMap);
    seriesCollection.addSeries(diagAvg);
    XYSeries pooledAvg = new XYSeries("Pooled Average", false);
    seriesCollection.addSeries(pooledAvg);

}

From source file:com.redhat.rhn.taskomatic.task.DailySummary.java

private StringBuffer renderActionTree(int longestActionLength, int longestStatusLength,
        LinkedHashSet<String> statusSet, TreeMap<String, Map<String, Integer>> actionTree) {
    StringBuffer formattedActions = new StringBuffer();
    for (String actionName : actionTree.keySet()) {
        formattedActions//from   ww w .j a va 2 s  . c o  m
                .append(actionName + StringUtils.repeat(" ", (longestActionLength - (actionName.length()))));
        for (String status : statusSet) {
            Map<String, Integer> counts = actionTree.get(actionName);
            Integer theCount = counts.get(status);
            if (counts.containsKey(status)) {
                theCount = counts.get(status);
            } else {
                theCount = 0;
            }
            formattedActions.append(theCount);
            formattedActions.append(StringUtils.repeat(" ",
                    longestStatusLength + ERRATA_SPACER - theCount.toString().length()));
        }
        formattedActions.append("\n");
    }
    return formattedActions;
}

From source file:org.apache.geode.BundledJarsJUnitTest.java

/**
 * Find all of the jars bundled with the project. Key is the name of the jar, value is the path.
 *///from   www .  j  a va2s . c o m
private TreeMap<String, String> getBundledJars() {
    File geodeHomeDirectory = new File(GEODE_HOME);

    assertTrue("Please set the GEODE_HOME environment variable to the product installation directory.",
            geodeHomeDirectory.isDirectory());

    Collection<File> jars = FileUtils.listFiles(geodeHomeDirectory, new String[] { "jar" }, true);
    TreeMap<String, String> sortedJars = new TreeMap<>();
    jars.forEach(jar -> sortedJars.put(jar.getName(), jar.getPath()));

    Collection<File> wars = FileUtils.listFiles(geodeHomeDirectory, new String[] { "war" }, true);
    TreeSet<File> sortedWars = new TreeSet<>(wars);
    sortedWars.stream().flatMap(BundledJarsJUnitTest::extractJarNames)
            .forEach(jar -> sortedJars.put(jar.getName(), jar.getPath()));

    sortedJars.keySet().removeIf(s -> s.startsWith("geode"));
    return sortedJars;
}

From source file:emlab.role.investment.InvestInPowerGenerationTechnologiesRole.java

private double npv(TreeMap<Integer, Double> netCashFlow, double wacc) {
    double npv = 0;
    for (Integer iterator : netCashFlow.keySet()) {
        npv += netCashFlow.get(iterator).doubleValue() / Math.pow(1 + wacc, iterator.intValue());
    }//from  w ww  .j a va  2s .  c om
    return npv;
}

From source file:edu.illinois.cs.cogcomp.core.datastructures.Lexicon.java

public void writeIntegerToFeatureStringFormat(PrintStream out) throws IOException {
    if (null == this.featureNames)
        throw new IllegalStateException("Error: Lexicon has not been configured to store feature names.");

    TreeMap<Integer, String> idToFeat = new TreeMap();

    for (String feat : this.featureNames) {
        int id = lookupId(feat);
        idToFeat.put(id, feat);/*  w ww. jav a  2s  .  c o  m*/
    }

    for (Integer id : idToFeat.keySet()) {
        out.print(id);
        out.print("\t");
        out.print(idToFeat.get(id));
    }
    out.flush();
}

From source file:com.sfs.whichdoctor.analysis.AgedDebtorsAnalysisDAOImpl.java

/**
 * Calculate the overall balance.//from   w  w  w . ja  v  a 2s  .co m
 *
 * @param groups the groups
 * @return the double
 */
private double calculateBalance(final TreeMap<String, AgedDebtorsGrouping> groups) {

    double balance = 0;

    for (String orderKey : groups.keySet()) {
        AgedDebtorsGrouping group = groups.get(orderKey);

        balance += group.getTotal();
    }
    return balance;
}

From source file:org.openiot.gsn.beans.StreamElement.java

public StreamElement(TreeMap<String, Serializable> output, DataField[] fields) {
    int nbFields = output.keySet().size();
    if (output.containsKey("timed"))
        nbFields--;/* ww  w.  jav  a 2s.  c o m*/
    String fieldNames[] = new String[nbFields];
    Byte fieldTypes[] = new Byte[nbFields];
    Serializable fieldValues[] = new Serializable[nbFields];
    TreeMap<String, Integer> indexedFieldNames = new TreeMap<String, Integer>(new CaseInsensitiveComparator());
    int idx = 0;

    long timestamp = System.currentTimeMillis();
    for (String key : output.keySet()) {
        Serializable value = output.get(key);

        if (key.equalsIgnoreCase("timed"))
            timestamp = (Long) value;
        else {
            fieldNames[idx] = key;
            fieldValues[idx] = value;
            for (int i = 0; i < fields.length; i++) {
                if (fields[i].getName().equalsIgnoreCase(key))
                    fieldTypes[idx] = fields[i].getDataTypeID();
            }
            indexedFieldNames.put(key, idx);
            idx++;
        }
    }
    this.fieldNames = fieldNames;
    this.fieldTypes = fieldTypes;
    this.fieldValues = fieldValues;
    this.indexedFieldNames = indexedFieldNames;
    this.timeStamp = timestamp;
}