List of usage examples for com.google.common.collect TreeMultimap create
public static <K, V> TreeMultimap<K, V> create(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator)
From source file:co.cask.cdap.common.zookeeper.coordination.ResourceAssignment.java
/** * Creates with the given assignment.//w w w . j a v a 2 s. com * * @param name Name of the resource. * @param assignments Set of assignments carries by this object. */ public ResourceAssignment(String name, Multimap<Discoverable, PartitionReplica> assignments) { this.name = name; TreeMultimap<Discoverable, PartitionReplica> multimap = TreeMultimap .create(DiscoverableComparator.COMPARATOR, PartitionReplica.COMPARATOR); multimap.putAll(assignments); this.assignments = Multimaps.unmodifiableSortedSetMultimap(multimap); }
From source file:org.sonar.batch.symbol.DefaultSymbolTableBuilder.java
public DefaultSymbolTableBuilder(String componentKey, ComponentDataCache cache) { this.componentKey = componentKey; this.cache = cache; this.referencesBySymbol = TreeMultimap.create(new SymbolComparator(), new ReferenceComparator()); }
From source file:de.hzi.helmholtz.Compare.ModuleClassThread.java
@Override public void run() { forward = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural()); PathwayComparisonWithModules comparison = new PathwayComparisonWithModules(source, target, yes, threadName); forward = comparison.SubsetsMatching(source, target, SourceGeneIdToPositionMap, TargetGeneIdToPositionMap, yes);//from w ww .j ava2s .co m // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:org.ambraproject.wombat.model.TaxonomyGraph.java
private static SortedSetMultimap<String, String> caseInsensitiveSetMultimap() { return TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, String.CASE_INSENSITIVE_ORDER); }
From source file:org.artifactory.repo.snapshot.VersionsRetriever.java
public VersionsRetriever(boolean reverseOrderResults) { if (reverseOrderResults) { versionsItems = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural().reverse()); } else {/*w ww. j ava 2s. c o m*/ versionsItems = TreeMultimap.create(Ordering.natural(), Ordering.natural()); } }
From source file:de.rkl.tools.tzconv.model.ApplicationModel.java
private static SetMultimap<ZoneOffset, ZoneId> sortAvailableZoneIds() { final SortedSetMultimap<ZoneOffset, ZoneId> zoneIdMap = TreeMultimap.create(Ordering.natural().reverse(), new Ordering<ZoneId>() { @Override//www . j ava 2 s . co m public int compare(final ZoneId zoneId1, final ZoneId zoneId2) { return ComparisonChain.start().compare(zoneId1.toString(), zoneId2.toString()).result(); } }.nullsFirst()); ZoneId.getAvailableZoneIds().stream().forEach(zoneId -> { final ZoneId zoneIdObject = ZoneId.of(zoneId); zoneIdMap.put(zoneIdObject.getRules().getStandardOffset(Instant.now()), zoneIdObject); }); return ImmutableSetMultimap.copyOf(zoneIdMap); }
From source file:hihex.cs.LogFiles.java
public void removeExpired(final Preferences preferences) { long purgeDuration = preferences.getPurgeDuration(); long purgeFilesize = preferences.getPurgeFilesize(); final TreeMultimap<Long, File> files = list(); // Don't use `TreeMultimap.create(files)`! The key comparator will be reverted to the natural one. final TreeMultimap<Long, File> filesToKeep = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural());//from www . jav a 2 s . c o m filesToKeep.putAll(files); if (purgeDuration >= 0) { final long expireDate = System.currentTimeMillis() - purgeDuration; filesToKeep.asMap().tailMap(expireDate).clear(); } if (purgeFilesize >= 0) { final Iterator<File> iterator = filesToKeep.values().iterator(); long currentFilesize = 0; while (iterator.hasNext()) { final File file = iterator.next(); if (currentFilesize > purgeFilesize) { iterator.remove(); } else { currentFilesize += file.length(); } } } files.entries().removeAll(filesToKeep.entries()); for (final File file : files.values()) { file.delete(); } }
From source file:org.gradle.api.tasks.diagnostics.internal.DefaultGroupTaskReportModel.java
public void build(TaskReportModel model) { Comparator<String> keyComparator = GUtil.last(GUtil.last(STRING_COMPARATOR, OTHER_GROUP), DEFAULT_GROUP); Comparator<TaskDetails> taskComparator = new Comparator<TaskDetails>() { public int compare(TaskDetails task1, TaskDetails task2) { int diff = STRING_COMPARATOR.compare(task1.getPath().getName(), task2.getPath().getName()); if (diff != 0) { return diff; }/*from ww w .jav a 2s . co m*/ Path parent1 = task1.getPath().getParent(); Path parent2 = task2.getPath().getParent(); if (parent1 == null && parent2 != null) { return -1; } if (parent1 != null && parent2 == null) { return 1; } if (parent1 == null) { return 0; } return parent1.compareTo(parent2); } }; groups = TreeMultimap.create(keyComparator, taskComparator); for (String group : model.getGroups()) { groups.putAll(group, model.getTasksForGroup(group)); } String otherGroupName = findOtherGroup(groups.keySet()); if (otherGroupName != null && groups.keySet().contains(DEFAULT_GROUP)) { groups.putAll(otherGroupName, groups.removeAll(DEFAULT_GROUP)); } if (groups.keySet().contains(DEFAULT_GROUP) && groups.keySet().size() > 1) { groups.putAll(OTHER_GROUP, groups.removeAll(DEFAULT_GROUP)); } }
From source file:net.shipilev.concurrent.torture.XMLtoHTMLResultPrinter.java
public XMLtoHTMLResultPrinter(Options opts) throws JAXBException, FileNotFoundException { resultDir = opts.getResultDest();// www.j a va2 s. co m testSuites = TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, new Comparator<Test>() { @Override public int compare(Test o1, Test o2) { return o1.getName().compareTo(o2.getName()); } }); readDescriptions(); }
From source file:moavns.EstruturasVizinhanca.java
public EstruturasVizinhanca(Solucao solucao) { this.startTime = System.currentTimeMillis(); this.linhasX = solucao.getLinhasX(); this.lista_de_colunas_gulosas = solucao.getColunas(); this.linhasCobertas = solucao.getLinhasCobertas(); this.qtdeLinhas = solucao.getQtdeLinhas(); this.qtdeColunas = solucao.getQtdeColunas(); this.custoTotal = solucao.getCustototal(); Comparator comparador = new Comparador(); Ordering<Integer> ordenacao = Ordering.natural(); Comparator ordenacao1 = ordenacao; Ordering<Solucao> ordenacao2 = Ordering.from(comparador); this.solucoes = TreeMultimap.create(ordenacao1, ordenacao2); }