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:com.yahoo.pulsar.broker.stats.BookieClientStatsGenerator.java

public BookieClientStatsGenerator(PulsarService pulsar) {
    this.pulsar = pulsar;
    this.nsBookieClientStatsMap = Maps.newTreeMap();
}

From source file:nl.knaw.huygens.timbuctoo.model.base.BaseLocation.java

@Override
public Map<String, String> getClientRepresentation() {
    Map<String, String> data = Maps.newTreeMap();
    addItemToRepresentation(data, "urn", getUrn());
    addItemToRepresentation(data, "latitude", getLatitude());
    addItemToRepresentation(data, "longitude", getLongitude());
    return data;/* w  w  w .j a v  a 2  s  . co m*/
}

From source file:nl.knaw.huygens.timbuctoo.model.ckcc.CKCCCollective.java

@Override
public Map<String, String> getClientRepresentation() {
    Map<String, String> data = Maps.newTreeMap();
    addItemToRepresentation(data, URN, getUrn());
    return data;//from   w w w  . jav  a2s. c  o  m
}

From source file:com.precioustech.fxtrading.instrument.InstrumentService.java

public InstrumentService(InstrumentDataProvider<T> instrumentDataProvider) {
    Preconditions.checkNotNull(instrumentDataProvider);
    Collection<TradeableInstrument<T>> instruments = instrumentDataProvider.getInstruments();
    Map<String, TradeableInstrument<T>> tradeableInstrumenMap = Maps.newTreeMap();
    for (TradeableInstrument<T> instrument : instruments) {
        tradeableInstrumenMap.put(instrument.getInstrument(), instrument);
    }//w  w w.j  a  v a 2s  . co  m
    this.instrumentMap = Collections.unmodifiableMap(tradeableInstrumenMap);
}

From source file:org.eel.kitchen.jsonschema.util.JacksonUtils.java

/**
 * Return a sorted map out of an object instance
 *
 * <p>This is used by syntax validation especially: it is more convenient to
 * present validation messages in key order.</p>
 *
 * @param node the node/*from  w  w w  .j ava2 s .c o  m*/
 * @return a mutable map made of the instance's entries
 */
public static SortedMap<String, JsonNode> nodeToTreeMap(final JsonNode node) {
    final SortedMap<String, JsonNode> ret = Maps.newTreeMap();

    final Iterator<Map.Entry<String, JsonNode>> iterator = node.fields();

    Map.Entry<String, JsonNode> entry;
    while (iterator.hasNext()) {
        entry = iterator.next();
        ret.put(entry.getKey(), entry.getValue());
    }

    return ret;
}

From source file:org.gradle.api.internal.tasks.FilePropertyContainer.java

protected SortedMap<String, FileCollection> collectFileProperties(
        Iterator<? extends TaskFilePropertySpec> fileProperties) {
    SortedMap<String, FileCollection> filePropertiesMap = Maps.newTreeMap();
    while (fileProperties.hasNext()) {
        TaskFilePropertySpec propertySpec = fileProperties.next();
        String propertyName = propertySpec.getPropertyName();
        if (filePropertiesMap.containsKey(propertyName)) {
            throw new IllegalArgumentException(
                    String.format("Multiple %s file properties with name '%s'", displayName, propertyName));
        }//from  w  w w.ja v  a2s.  c  o  m
        filePropertiesMap.put(propertyName, propertySpec.getPropertyFiles());
    }
    return ImmutableSortedMap.copyOf(filePropertiesMap);
}

From source file:org.sonar.plugins.j3c.domain.CoverageComplexityDataSet.java

public CoverageComplexityDataSet() {
    this.dataSet = Maps.newTreeMap();
}

From source file:com.spotify.folsom.ketama.Continuum.java

private TreeMap<Integer, RawMemcacheClient> buildRing(final Collection<AddressAndClient> clients) {

    final TreeMap<Integer, RawMemcacheClient> r = Maps.newTreeMap();
    for (final AddressAndClient client : clients) {
        final String address = client.getAddress().toString();

        byte[] hash = addressToBytes(address);
        for (int i = 0; i < VNODE_RATIO; i++) {
            final HashCode hashCode = Hasher.hash(hash);
            hash = hashCode.asBytes();/* w  ww .  j  a  va  2  s.  co  m*/
            r.put(hashCode.asInt(), client.getClient());
        }
    }
    return r;
}

From source file:org.apache.kylin.storage.hbase.coprocessor.AggregationCache.java

public AggregationCache() {
    this.aggBufMap = Maps.newTreeMap();
}

From source file:com.memonews.mahout.sentiment.SGDHelper.java

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

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

    final SentimentModelHelper helper = new SentimentModelHelper();
    helper.getEncoder().setTraceDictionary(traceDictionary);
    helper.getBias().setTraceDictionary(traceDictionary);

    for (final File file : permute(files, helper.getRandom()).subList(0, 500)) {
        traceDictionary.clear();
        final Vector v = helper.encodeFeatureVector(file, overallCounts);
        md.update(v, traceDictionary, model);
    }

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