Example usage for com.google.common.collect Maps newTreeMap

List of usage examples for com.google.common.collect Maps newTreeMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newTreeMap.

Prototype

public static <K extends Comparable, V> TreeMap<K, V> newTreeMap() 

Source Link

Document

Creates a mutable, empty TreeMap instance using the natural ordering of its elements.

Usage

From source file:org.graylog2.restclient.models.api.responses.metrics.MetricsListResponse.java

public Map<String, Metric> getMetrics() {
    Map<String, Metric> result = Maps.newTreeMap();

    for (MetricsListItem m : metrics) {
        result.put(m.fullName, m.getMetric());
    }/*w w w. j a  v a 2 s.c  o m*/

    return result;
}

From source file:org.apache.mahout.classifier.sgd.SGDHelper.java

public static void dissect(int leakType, Dictionary dictionary, AdaptiveLogisticRegression learningAlgorithm,
        Iterable<File> files, Multiset<String> overallCounts) throws IOException {
    CrossFoldLearner model = learningAlgorithm.getBest().getPayload().getLearner();
    model.close();//from   w w  w  . j a  v a 2 s.  com

    Map<String, Set<Integer>> traceDictionary = Maps.newTreeMap();
    ModelDissector md = new ModelDissector();

    NewsgroupHelper helper = new NewsgroupHelper();
    helper.getEncoder().setTraceDictionary(traceDictionary);
    helper.getBias().setTraceDictionary(traceDictionary);

    for (File file : permute(files, helper.getRandom()).subList(0, 500)) {
        String ng = file.getParentFile().getName();
        int actual = dictionary.intern(ng);

        traceDictionary.clear();
        Vector v = helper.encodeFeatureVector(file, actual, leakType, overallCounts);
        md.update(v, traceDictionary, model);
    }

    List<String> ngNames = Lists.newArrayList(dictionary.values());
    List<ModelDissector.Weight> weights = md.summary(100);
    System.out.println("============");
    System.out.println("Model Dissection");
    for (ModelDissector.Weight w : weights) {
        System.out.printf("%s\t%.1f\t%s\t%.1f\t%s\t%.1f\t%s%n", w.getFeature(), w.getWeight(),
                ngNames.get(w.getMaxImpact() + 1), w.getCategory(1), w.getWeight(1), w.getCategory(2),
                w.getWeight(2));
    }
}

From source file:org.eclipse.viatra.query.runtime.registry.data.QuerySpecificationStore.java

/**
 * Creates a new instance with an empty identifier to source map.
 */
public QuerySpecificationStore() {
    this.sources = Maps.newTreeMap();
}

From source file:io.airlift.configuration.ConfigurationLoader.java

public Map<String, String> loadProperties() throws IOException {
    Map<String, String> result = Maps.newTreeMap();
    String configFile = System.getProperty("config");
    if (configFile != null) {
        result.putAll(loadPropertiesFrom(configFile));
    }//w w  w  .j a  v  a  2 s. c  om

    result.putAll(getSystemProperties());

    return ImmutableSortedMap.copyOf(result);
}

From source file:com.fractal.facebooksentiment.processor.FacebookSentimentCalculator.java

private FacebookSentimentCalculator() {
    commentSentimentMap = Maps.newTreeMap();
    afinnSentimentMap = Maps.newTreeMap();

    try {//from  www.j  av a  2s. c  o m
        final URL url = Resources.getResource(Constants.AFINN_SENTIMENT_FILE_NAME);
        final String text = Resources.toString(url, Charsets.UTF_8);
        final Iterable<String> lineSplit = Splitter.on("\n").trimResults().omitEmptyStrings().split(text);
        List<String> tabSplit;
        for (final String str : lineSplit) {
            tabSplit = Lists.newArrayList(Splitter.on("\t").trimResults().omitEmptyStrings().split(str));
            afinnSentimentMap.put(tabSplit.get(0), Integer.parseInt(tabSplit.get(1)));
        }
    } catch (final IOException ioException) {
        ioException.printStackTrace();
        // Should not occur. If it occurs, we cant continue. So, exiting at this point itself.
        // System.exit(1);
    }
}

From source file:org.sonatype.nexus.yum.internal.capabilities.AliasMappings.java

public AliasMappings(final Map<String, String> aliases) {
    this.aliases = Maps.newTreeMap();
    this.aliases.putAll(checkNotNull(aliases));
}

From source file:nl.knaw.huygens.timbuctoo.index.IndexStatus.java

public IndexStatus() {
    counts = Maps.newTreeMap();
}

From source file:com.enonic.cms.core.tools.plugin.PluginInfoController.java

@SuppressWarnings("unchecked")
private Map<String, List<String>> createExtMap() {
    final Map<String, List<String>> map = Maps.newTreeMap();
    for (final ExtensionPoint point : this.extensionPoints) {
        map.put(point.getName(), point.toHtml());
    }//  ww w .j av a2 s .co  m

    return map;
}

From source file:nl.knaw.huygens.tei.ElementAnalyzerVisitor.java

public ElementAnalyzerVisitor() {
    counts = Maps.newTreeMap();
}

From source file:org.sonar.server.platform.monitoring.JvmPropertiesMonitor.java

@Override
public LinkedHashMap<String, Object> attributes() {
    SortedMap<String, Object> sortedProps = Maps.newTreeMap();
    for (Map.Entry<Object, Object> systemProp : System.getProperties().entrySet()) {
        sortedProps.put(Objects.toString(systemProp.getKey()), Objects.toString(systemProp.getValue()));
    }//from  ww  w.j a  v  a  2s . c  o  m
    return new LinkedHashMap<>(sortedProps);
}