List of usage examples for com.google.common.collect Maps newTreeMap
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap()
From source file:com.commercehub.dropwizard.mongeez.MongoCommand.java
public MongoCommand(MongoConfiguration<T> mongoConfiguration, Class<T> configurationClass) { super("mongo", "Run MongoDB migration tasks", mongoConfiguration, configurationClass); this.subcommands = Maps.newTreeMap(); addSubcommand(new MongoMigrateCommand<>(mongoConfiguration, configurationClass)); }
From source file:org.apache.crunch.impl.spark.CounterAccumulatorParam.java
@Override public Map<String, Map<String, Long>> addAccumulator(Map<String, Map<String, Long>> current, Map<String, Map<String, Long>> added) { for (Map.Entry<String, Map<String, Long>> e : added.entrySet()) { Map<String, Long> grp = current.get(e.getKey()); if (grp == null) { grp = Maps.newTreeMap(); current.put(e.getKey(), grp); }//w w w. j a v a 2s . co m for (Map.Entry<String, Long> f : e.getValue().entrySet()) { Long cnt = grp.get(f.getKey()); cnt = (cnt == null) ? f.getValue() : cnt + f.getValue(); grp.put(f.getKey(), cnt); } } return current; }
From source file:com.facebook.buck.java.abi.AnnotationMirror.java
public AnnotationMirror(String desc, boolean visible) { super(Opcodes.ASM5); this.desc = desc; this.visible = visible; this.values = Maps.newTreeMap(); }
From source file:com.palantir.atlasdb.cleaner.InMemoryPuncherStore.java
private final TreeMap<Long, Long> makeMap() { TreeMap<Long, Long> map1 = Maps.newTreeMap(); map1.put(Long.MIN_VALUE, Long.MIN_VALUE); return map1;//from w w w . j a v a2 s .com }
From source file:de.tu_berlin.dima.oligos.stat.distribution.histogram.StringHistogram.java
public StringHistogram() { this.exactValues = Maps.newTreeMap(); this.total = 0l; }
From source file:com.lewisd.maven.lint.plugin.ListRulesMojo.java
public void execute() throws MojoExecutionException, MojoFailureException { init();/*w ww . jav a 2s . c om*/ Collection<AbstractRule> rules = getContext().getBeansOfType(AbstractRule.class).values(); Map<String, AbstractRule> name2ruleMap = Maps.newTreeMap(); for (AbstractRule rule : rules) { name2ruleMap.put(rule.getIdentifier(), rule); } StringBuilder buffer = new StringBuilder(); for (Map.Entry<String, AbstractRule> entry : name2ruleMap.entrySet()) { AbstractRule rule = entry.getValue(); buffer.append("- ").append(rule.getIdentifier()).append("\n\n").append(formatAsBlock(rule)) .append("\n\n"); } System.out.println(buffer.toString().replaceFirst("\n$", "")); }
From source file:com.cloudera.science.ml.parallel.pobject.ListOfListsPObject.java
@Override protected List<List<V>> process(Iterable<Pair<Pair<Integer, Integer>, V>> input) { SortedMap<Integer, SortedMap<Integer, V>> sm = Maps.newTreeMap(); for (Pair<Pair<Integer, Integer>, V> p : input) { int center = p.first().first(); SortedMap<Integer, V> inner = sm.get(center); if (inner == null) { inner = Maps.newTreeMap();/*w w w .j a va2 s . co m*/ sm.put(center, inner); } inner.put(p.first().second(), p.second()); } List<List<V>> ret = Lists.newArrayList(); for (int i = 0; i < expected.length; i++) { SortedMap<Integer, V> e = sm.get(i); if (e == null) { ret.add(null); } else { List<V> v = Lists.newArrayList(); for (int j = 0; j < expected[i]; j++) { V value = e.get(j); if (value == null) { v.add(emptyValue); } else { v.add(value); } } ret.add(v); } } return ret; }
From source file:org.sonar.batch.tasks.Tasks.java
public Tasks(TaskDefinition[] definitions) { SortedMap<String, TaskDefinition> map = Maps.newTreeMap(); for (TaskDefinition definition : definitions) { if (map.containsKey(definition.key())) { throw new SonarException("Task '" + definition.key() + "' is declared twice"); }//from www . j a va 2s . c o m map.put(definition.key(), definition); } this.byKey = ImmutableSortedMap.copyOf(map); }
From source file:org.sonar.batch.task.Tasks.java
public Tasks(TaskDefinition[] definitions) { SortedMap<String, TaskDefinition> map = Maps.newTreeMap(); for (TaskDefinition definition : definitions) { if (map.containsKey(definition.key())) { throw new IllegalStateException("Task '" + definition.key() + "' is declared twice"); }//from w w w. j a v a 2 s. c o m map.put(definition.key(), definition); } this.byKey = ImmutableSortedMap.copyOf(map); }
From source file:org.gradoop.flink.algorithms.fsm.transactional.common.functions.SortedDictionary.java
@Override public void reduce(Iterable<WithCount<String>> iterable, Collector<Map<String, Integer>> collector) throws Exception { Map<String, Integer> dictionary = Maps.newHashMap(); Map<Long, Collection<String>> sortedLabels = Maps.newTreeMap(); for (WithCount<String> labelFrequency : iterable) { String label = labelFrequency.getObject(); Long frequency = labelFrequency.getCount(); Collection<String> siblings = sortedLabels.computeIfAbsent(frequency, k -> new TreeSet<>()); siblings.add(label);/* w ww.j a v a 2 s.c o m*/ } int translation = 0; for (Collection<String> siblings : sortedLabels.values()) { for (String label : siblings) { dictionary.put(label, translation); translation++; } } collector.collect(dictionary); }