/** * @since 10.0 - Override for correctness */ @Override public void sort(Comparator<? super T> comparator) { this.delegate.sort(comparator); }
/** * Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList. */ public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator) { list.sort(comparator); return list; }
/** * Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList. */ public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator) { list.sort(comparator); return list; }
/** * @since 10.0 - Override for correctness */ @Override public void sort(Comparator<? super T> comparator) { this.delegate.sort(comparator); }
private StageIdFaninScmMaterialPair getSmallestScmRevision(Collection<StageIdFaninScmMaterialPair> scmWithDiffVersions) { ArrayList<StageIdFaninScmMaterialPair> materialPairList = new ArrayList<>(scmWithDiffVersions); materialPairList.sort((pair1, pair2) -> { final PipelineTimelineEntry.Revision rev1 = pair1.faninScmMaterial.revision; final PipelineTimelineEntry.Revision rev2 = pair2.faninScmMaterial.revision; return rev1.date.compareTo(rev2.date); }); return materialPairList.get(0); }
public String usage() { StringBuilder sb = new StringBuilder(); if ( !namedArgs.isEmpty() ) { sb.append( namedArgs.values().stream().map( NamedArgument::usage ).collect( Collectors.joining( " " ) ) ); } if ( !positionalArgs.isEmpty() ) { sb.append( " " ); positionalArgs.sort( Comparator.comparingInt( PositionalArgument::position ) ); sb.append( positionalArgs.stream().map( PositionalArgument::usage ).collect( Collectors.joining( " " ) ) ); } return sb.toString().trim(); }
@Override public List<Revision> revisions() { ArrayList<Revision> revisions = new ArrayList<>(this.revisions); revisions.sort((o1, o2) -> ((PipelineRevision) o1).compareTo((PipelineRevision) o2)); return revisions; }
@Override public List<Revision> revisions() { ArrayList<Revision> revisions = new ArrayList<>(this.revisions); for(MaterialRevision revision : materialRevisions) { for(Modification modification : revision.getModifications()) { revisions.add(new SCMRevision(modification)); } } revisions.sort(Comparator.comparing(o -> ((SCMRevision) o))); return revisions; }
private Transfer findMostSpecificRule(List<Transfer> transfers, String fromRouteId, String toRouteId) { final ArrayList<Transfer> transfersBySpecificity = new ArrayList<>(transfers); transfersBySpecificity.sort(Comparator.comparingInt(t -> { int score = 0; if (fromRouteId.equals(t.from_route_id)) { score++; } if (toRouteId.equals(t.to_route_id)) { score++; } return -score; })); if (transfersBySpecificity.isEmpty()) { throw new RuntimeException(); } return transfersBySpecificity.get(0); }
long send() { // Sort in reverse, so the elements we want to send first are at the end. batches.sort( TICKETED_BATCH_COMPARATOR ); long idleTimeSum = 0; long batchesDone = 0; for ( int i = batches.size() - 1; i >= 0 ; i-- ) { TicketedBatch batch = batches.get( i ); if ( batch.ticket == lastSendTicket + 1 ) { batches.remove( i ); lastSendTicket = batch.ticket; idleTimeSum += downstream.receive( batch.ticket, batch.batch ); batchesDone++; } else { break; } } doneBatches.getAndAdd( batchesDone ); return idleTimeSum; }
/** * Returns an ordered list of edges in the graph. * This creates and sorts a list, so prefer edgeIterable(). * * @return A ordered list of edges in the graph. */ public List<SemanticGraphEdge> edgeListSorted() { ArrayList<SemanticGraphEdge> edgeList = new ArrayList<>(); for (SemanticGraphEdge edge : edgeIterable()) { edgeList.add(edge); } edgeList.sort(SemanticGraphEdge.orderByTargetComparator()); return edgeList; }
/** * Gets all the users. */ public static @Nonnull Collection<User> getAll() { final IdStrategy strategy = idStrategy(); ArrayList<User> users = new ArrayList<>(AllUsers.values()); users.sort((o1, o2) -> strategy.compare(o1.getId(), o2.getId())); return users; }
@NotNull public List<Mark> getMarks(@NotNull Editor editor) { HashSet<Mark> res = new HashSet<>(); final FileMarks<Character, Mark> marks = getFileMarks(editor.getDocument()); if (marks != null) { res.addAll(marks.values()); } res.addAll(globalMarks.values()); ArrayList<Mark> list = new ArrayList<>(res); list.sort(new Mark.KeySorter<>()); return list; }
@SuppressWarnings("unchecked") private void addAllTestResults(Set<ITestResult> testResults, IResultMap resultMap) { if (resultMap != null) { // Sort the results chronologically before adding them List<ITestResult> allResults = new ArrayList<>(resultMap.getAllResults()); new ArrayList(allResults) .sort( (Comparator<ITestResult>) (o1, o2) -> (int) (o1.getStartMillis() - o2.getStartMillis())); testResults.addAll(allResults); } }
methods.sort((m1, m2) -> { int m1pl = m1.getParameterCount(); int m2pl = m2.getParameterCount();
out.sort( Comparator.comparing( a -> a.signature().name().toString() ) ); return out;
out.sort( Comparator.comparing( a -> a.signature().name().toString() ) ); return out;
out.sort( Comparator.comparing( a -> a.signature().name().toString() ) ); return out;
public List<JobInstanceModel> jobInstanceModelFor(JobInstances jobInstances) { ArrayList<JobInstanceModel> models = new ArrayList<>(); for (JobInstance jobInstance : jobInstances) { AgentInstance agentInstance = jobInstance.isAssignedToAgent() ? agentService.findAgentAndRefreshStatus(jobInstance.getAgentUuid()) : null; JobInstanceModel model; if (null != agentInstance && !agentInstance.isNullAgent()) { model = new JobInstanceModel(jobInstance, jobDurationStrategy, agentInstance); } else if (jobInstance.getAgentUuid() != null) { Agent agent = agentService.findAgentObjectByUuid(jobInstance.getAgentUuid()); model = new JobInstanceModel(jobInstance, jobDurationStrategy, agent); } else { model = new JobInstanceModel(jobInstance, jobDurationStrategy); } models.add(model); } models.sort(JobInstanceModel.JOB_MODEL_COMPARATOR); return models; } }
list.sort(Integer::compare); assertEquals(list, ImmutableList.of(1, 2, 3, 4, 5)); assertTrue(queue.isFinished());