List of usage examples for com.google.common.collect Sets newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
From source file:eu.interedition.collatex.medite.AlignmentDecisionGraph.java
static SortedSet<SortedSet<VertexMatch.WithTokenIndex>> filter( SortedSet<SortedSet<VertexMatch.WithTokenIndex>> matches, Function<SortedSet<VertexMatch.WithTokenIndex>, Integer> matchEvaluator) { final SortedSet<SortedSet<VertexMatch.WithTokenIndex>> alignments = Sets .newTreeSet(VertexMatch.<VertexMatch.WithTokenIndex>setComparator()); final List<SortedSet<VertexMatch.WithTokenIndex>> matchList = Lists.newArrayList(matches); Node optimal = new AlignmentDecisionGraph(matchList, matchEvaluator).findBestPath(); while (optimal.matchIndex >= 0) { if (optimal.aligned) { alignments.add(matchList.get(optimal.matchIndex)); }//from www . j a v a 2 s . c o m optimal = optimal.previous; } return alignments; }
From source file:org.terasology.polyworld.voronoi.Region.java
/** * @param centerPos the center of the region *//* ww w . jav a2 s. c om*/ public Region(Vector2f centerPos) { this.center = centerPos; this.corners = Sets.newTreeSet(new AngleOrdering(centerPos)); this.borders = Sets.newLinkedHashSet(); this.neighbors = Sets.newLinkedHashSet(); }
From source file:uk.ac.ebi.spot.rdf.model.differential.microarray.MicroarrayExperimentConfiguration.java
public MicroarrayExperimentConfiguration(XMLConfiguration xmlConfiguration, Document document) { super(xmlConfiguration, document); this.arrayDesignAccessions = Sets.newTreeSet((List) xmlConfiguration.getList("analytics/array_design")); }
From source file:io.druid.indexing.overlord.setup.EqualDistributionWorkerSelectStrategy.java
@Override public Optional<ImmutableZkWorker> findWorkerForTask(RemoteTaskRunnerConfig config, ImmutableMap<String, ImmutableZkWorker> zkWorkers, Task task) { final TreeSet<ImmutableZkWorker> sortedWorkers = Sets.newTreeSet(new Comparator<ImmutableZkWorker>() { @Override/* w w w .j a va 2 s .c om*/ public int compare(ImmutableZkWorker zkWorker, ImmutableZkWorker zkWorker2) { return -Ints.compare(zkWorker2.getCurrCapacityUsed(), zkWorker.getCurrCapacityUsed()); } }); sortedWorkers.addAll(zkWorkers.values()); final String minWorkerVer = config.getMinWorkerVersion(); for (ImmutableZkWorker zkWorker : sortedWorkers) { if (zkWorker.canRunTask(task) && zkWorker.isValidVersion(minWorkerVer)) { return Optional.of(zkWorker); } } return Optional.absent(); }
From source file:com.android.sdklib.SdkManagerTest7.java
public void testSdkManager_getBuildTools() { // There is no build-tools folder in this repository. SdkManager sdkman = getSdkManager(); Set<FullRevision> v = sdkman.getBuildTools(); // Make sure we get a stable set -- hashmap order isn't stable and can't be used in tests. if (!(v instanceof TreeSet<?>)) { v = Sets.newTreeSet(v); }//www. jav a2 s.co m assertEquals("", getLog().toString()); // no errors in the logger assertEquals("[]", Arrays.toString(v.toArray())); assertNull(sdkman.getBuildTool(new FullRevision(1))); assertNull(sdkman.getBuildTool(new FullRevision(3, 0, 0))); assertNull(sdkman.getBuildTool(new FullRevision(12, 3, 4, 5))); }
From source file:org.terasology.polyworld.graph.Region.java
/** * @param centerPos the center of the region *///from w ww . jav a2 s .c o m public Region(ImmutableVector2f centerPos) { this.center = centerPos; this.corners = Sets.newTreeSet(new AngleOrdering(centerPos)); this.borders = Sets.newLinkedHashSet(); this.neighbors = Sets.newLinkedHashSet(); }
From source file:sc.calendar.dataSource.AndroidCalendar.java
public Set<CalendarEvent> getEvents() { return Sets.newTreeSet(events.values()); }
From source file:org.sonar.batch.highlighting.SyntaxHighlightingDataBuilder.java
public SyntaxHighlightingDataBuilder() { syntaxHighlightingRuleSet = Sets.newTreeSet(new Ordering<SyntaxHighlightingRule>() { @Override/* w w w. j a va2s. c o m*/ public int compare(@Nullable SyntaxHighlightingRule left, @Nullable SyntaxHighlightingRule right) { int result = left.getStartPosition() - right.getStartPosition(); if (result == 0) { result = left.getEndPosition() - right.getEndPosition(); } return result; } }); }
From source file:io.druid.indexing.overlord.setup.FillCapacityWorkerSelectStrategy.java
@Override public Optional<ImmutableZkWorker> findWorkerForTask(final RemoteTaskRunnerConfig config, final ImmutableMap<String, ImmutableZkWorker> zkWorkers, final Task task) { TreeSet<ImmutableZkWorker> sortedWorkers = Sets.newTreeSet(new Comparator<ImmutableZkWorker>() { @Override/*from w w w . jav a 2 s.c om*/ public int compare(ImmutableZkWorker zkWorker, ImmutableZkWorker zkWorker2) { int retVal = Ints.compare(zkWorker2.getCurrCapacityUsed(), zkWorker.getCurrCapacityUsed()); if (retVal == 0) { retVal = zkWorker.getWorker().getHost().compareTo(zkWorker2.getWorker().getHost()); } return retVal; } }); sortedWorkers.addAll(zkWorkers.values()); final String minWorkerVer = config.getMinWorkerVersion(); for (ImmutableZkWorker zkWorker : sortedWorkers) { if (zkWorker.canRunTask(task) && zkWorker.isValidVersion(minWorkerVer)) { return Optional.of(zkWorker); } } return Optional.absent(); }
From source file:org.gradle.internal.component.NoMatchingConfigurationSelectionException.java
private static String generateMessage(AttributeContainer fromConfigurationAttributes, AttributesSchema consumerSchema, ComponentResolveMetadata targetComponent, List<String> configurationNames) { List<ConfigurationMetadata> configurations = new ArrayList<ConfigurationMetadata>( configurationNames.size());// www . ja v a2s .co m for (String name : configurationNames) { ConfigurationMetadata targetComponentConfiguration = targetComponent.getConfiguration(name); if (targetComponentConfiguration.isCanBeConsumed() && !targetComponentConfiguration.getAttributes().isEmpty()) { configurations.add(targetComponentConfiguration); } } Set<String> requestedAttributes = Sets .newTreeSet(Iterables.transform(fromConfigurationAttributes.keySet(), ATTRIBUTE_NAME)); StringBuilder sb = new StringBuilder( "Unable to find a matching configuration in '" + targetComponent + "' :"); if (configurations.isEmpty()) { sb.append(" None of the consumable configurations have attributes."); } else { sb.append("\n"); int maxConfLength = maxLength(configurationNames); // We're sorting the names of the configurations and later attributes // to make sure the output is consistently the same between invocations for (final String config : configurationNames) { formatConfiguration(sb, fromConfigurationAttributes, consumerSchema, configurations, requestedAttributes, maxConfLength, config); } } return sb.toString(); }