List of usage examples for com.google.common.collect ImmutableSortedMap copyOf
public static <K, V> ImmutableSortedMap<K, V> copyOf( Iterable<? extends Entry<? extends K, ? extends V>> entries, Comparator<? super K> comparator)
From source file:org.apache.calcite.util.NameMap.java
/** Creates a NameMap that is an immutable copy of a given map. */ public static <V> NameMap immutableCopyOf(Map<String, V> names) { return new NameMap<>(ImmutableSortedMap.copyOf(names, COMPARATOR)); }
From source file:uk.ac.open.kmi.iserve.discovery.api.ranking.impl.ReverseRanker.java
@Override public SortedMap<URI, Double> rank(Map<URI, Double> map) { Ordering<URI> byScoreOrdering = Ordering.natural().onResultOf(Functions.forMap(map)) .compound(Ordering.usingToString()); return ImmutableSortedMap.copyOf(map, byScoreOrdering); }
From source file:uk.ac.open.kmi.iserve.discovery.api.ranking.impl.StandardRanker.java
@Override public SortedMap<URI, Double> rank(Map<URI, Double> map) { Ordering<URI> byScoreOrdering = Ordering.natural().reverse().onResultOf(Functions.forMap(map)) .compound(Ordering.usingToString()); return ImmutableSortedMap.copyOf(map, byScoreOrdering); }
From source file:org.sosy_lab.solver.Model.java
public static void appendModel(Appendable output, Map<AssignableTerm, Object> data) throws IOException { Map<AssignableTerm, Object> sorted = ImmutableSortedMap.copyOf(data, Ordering.usingToString()); joiner.appendTo(output, sorted);/*from w w w. j a v a2 s. c o m*/ }
From source file:com.insightml.data.features.stats.FeaturesImportance.java
@Override public String getText(final ISamples<?, Double> instances, final int labelIndex) { final FeatureStatistics stats = new FeatureStatistics(instances, labelIndex); final Map<String, Double> mi = new MutualInformation(0.1).run(stats); final Map<String, Double> chi = new ChiSquare(0.1).run(stats); final StringBuilder builder = new StringBuilder(1024); final SimpleFormatter formatter = new SimpleFormatter(5, true); for (final Entry<String, Double> feature : ImmutableSortedMap .copyOf(mi, Ordering.natural().reverse().onResultOf(Functions.forMap(mi))).entrySet()) { builder.append(UiUtils.fill(feature.getKey(), 25) + "\t"); builder.append("MutualInformation: " + UiUtils.fill(formatter.format(feature.getValue()), 12)); builder.append("ChiSquare: " + UiUtils.fill(formatter.format(chi.get(feature.getKey())), 12)); builder.append("\n"); }/*from w w w .j ava 2 s . co m*/ return builder.toString(); }
From source file:org.ambraproject.wombat.model.TaxonomyCountTable.java
public TaxonomyCountTable(Collection<SubjectCount> counts) { this.counts = ImmutableSortedMap.copyOf(Maps.uniqueIndex(counts, SubjectCount::getSubject), String.CASE_INSENSITIVE_ORDER); }
From source file:org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration.java
void setFields(Map<String, Field> fields) { Function<Field, String> getName = new Function<Field, String>() { public String apply(Field item) { return item.getName(); }//from w ww . jav a 2 s. c om }; Function<String, String> comparatorFunction = Functions.compose(getName, Functions.forMap(fields)); Ordering<String> comparator = Ordering.natural().onResultOf(comparatorFunction); this.fields = ImmutableSortedMap.copyOf(fields, comparator); }
From source file:org.ow2.authzforce.core.pdp.impl.policy.PolicyVersions.java
/** * Creates instance// w ww . java 2 s . c om * * @param versions * policy versions */ public PolicyVersions(final Map<PolicyVersion, P> versions) { policiesByVersion = versions == null ? ImmutableSortedMap.<PolicyVersion, P>of() : ImmutableSortedMap.copyOf(versions, Collections.reverseOrder()); }
From source file:com.google.jimfs.FileTree.java
/** * Creates a new file tree with the given root directories. */ FileTree(Map<Name, File> roots) { this.roots = ImmutableSortedMap.copyOf(roots, Name.canonicalOrdering()); }
From source file:com.google.devtools.build.lib.analysis.actions.CreateIncSymlinkAction.java
/** * Creates a new instance. The symlinks map maps symlinks to their targets, i.e. the symlink paths * must be unique, but several of them can point to the same target. *//*from w w w . j a v a 2 s . co m*/ public CreateIncSymlinkAction(ActionOwner owner, Map<Artifact, Artifact> symlinks) { super(owner, ImmutableList.copyOf(symlinks.values()), ImmutableList.copyOf(symlinks.keySet())); this.symlinks = ImmutableSortedMap.copyOf(symlinks, Artifact.EXEC_PATH_COMPARATOR); }