@Override public Comparator<ENTITY> thenComparingLong( ToLongFunction<? super ENTITY> keyExtractor) { return asCombined().thenComparingLong(keyExtractor); }
public MultiCriteriaLabelSetting(GraphExplorer explorer, PtFlagEncoder flagEncoder, boolean reverse, double maxWalkDistancePerLeg, boolean ptOnly, boolean mindTransfers, boolean profileQuery, int maxVisitedNodes, List<Label> solutions) { this.flagEncoder = flagEncoder; this.maxVisitedNodes = maxVisitedNodes; this.explorer = explorer; this.reverse = reverse; this.maxWalkDistancePerLeg = maxWalkDistancePerLeg; this.ptOnly = ptOnly; this.mindTransfers = mindTransfers; this.profileQuery = profileQuery; this.targetLabels = solutions; queueComparator = Comparator .comparingLong(this::weight) .thenComparingLong(l -> l.nTransfers) .thenComparingLong(l -> l.walkTime) .thenComparingLong(l -> departureTimeCriterion(l) != null ? departureTimeCriterion(l) : 0) .thenComparingLong(l -> l.impossible ? 1 : 0); fromHeap = new PriorityQueue<>(queueComparator); fromMap = new IntObjectHashMap<>(); }
@Override public Comparator<ScanInfo> createComparator(CreateParameters params) { Preconditions.checkArgument(params.getOptions().isEmpty()); Comparator<ScanInfo> c1 = (si1, si2) -> { long currTime = System.currentTimeMillis(); return Double.compare(idleRatio(currTime, si1), idleRatio(currTime, si2)); }; return c1.thenComparingLong(si -> si.getLastRunTime().orElse(0)) .thenComparingLong(ScanInfo::getCreationTime); } }
@Override public Comparator<ScanInfo> createComparator(CreateParameters params) { int defaultPriority = Integer .parseInt(params.getOptions().getOrDefault("default_priority", Integer.MAX_VALUE + "")); HintProblemAction hpa = HintProblemAction.valueOf(params.getOptions() .getOrDefault("bad_hint_action", HintProblemAction.LOG.name()).toUpperCase()); Comparator<ScanInfo> cmp = Comparator.comparingInt(si -> getPriority(si, defaultPriority, hpa)); return cmp.thenComparingLong(si -> si.getLastRunTime().orElse(0)) .thenComparingLong(ScanInfo::getCreationTime); } }
public static Comparator<IProcessedEvent> forProcessed() { return (Comparator<IProcessedEvent>) byPreviousEvents.thenComparingLong(IEvent::getDepth) .thenComparing(IEvent::getTimestamp); }
public static Comparator<IEvent> forEvent() { return (Comparator<IEvent>) byPreviousEvents.thenComparingLong(IEvent::getDepth) .thenComparing(IEvent::getTimestamp); }
@Override public List<ChannelCategory> getChannelCategories() { return Collections.unmodifiableList(getUnorderedChannels().stream() .filter(channel -> channel instanceof ChannelCategory) .sorted(Comparator.comparingInt(ServerChannel::getRawPosition).thenComparingLong(ServerChannel::getId)) .map(channel -> (ChannelCategory) channel) .collect(Collectors.toList())); }
@Override public List<ServerTextChannel> getTextChannels() { return Collections.unmodifiableList(getUnorderedChannels().stream() .filter(channel -> channel instanceof ServerTextChannel) .sorted(Comparator.comparingInt(ServerChannel::getRawPosition).thenComparingLong(ServerChannel::getId)) .map(channel -> (ServerTextChannel) channel) .collect(Collectors.toList())); }
@Override public List<ServerVoiceChannel> getVoiceChannels() { return Collections.unmodifiableList(getUnorderedChannels().stream() .filter(channel -> channel instanceof ServerVoiceChannel) .sorted(Comparator.comparingInt(ServerChannel::getRawPosition).thenComparingLong(ServerChannel::getId)) .map(channel -> (ServerVoiceChannel) channel) .collect(Collectors.toList())); }
@Override public Comparator<ENTITY> thenComparingLong( ToLongFunction<? super ENTITY> keyExtractor) { return asCombined().thenComparingLong(keyExtractor); }
@Override public List<ServerChannel> getChannels() { List<ServerChannel> channels = this.channels.values().stream() .filter(channel -> channel.asCategorizable() .map(categorizable -> !categorizable.getCategory().isPresent()) .orElse(false)) .sorted(Comparator .<ServerChannel>comparingInt(channel -> channel.getType().getId()) .thenComparingInt(ServerChannel::getRawPosition) .thenComparingLong(ServerChannel::getId)) .collect(Collectors.toList()); getChannelCategories().forEach(category -> { channels.add(category); channels.addAll(category.getChannels()); }); return Collections.unmodifiableList(channels); }
@Override public List<ServerChannel> getChannels() { return Collections.unmodifiableList( ((ServerImpl) getServer()).getUnorderedChannels().stream() .filter(channel -> channel.asCategorizable() .flatMap(Categorizable::getCategory) .map(this::equals) .orElse(false)) .sorted(Comparator .<ServerChannel>comparingInt(channel -> channel.getType().getId()) .thenComparingInt(ServerChannel::getRawPosition) .thenComparingLong(ServerChannel::getId)) .collect(Collectors.toList())); }
return prefixAndPostfix(title) .stream() .max(Comparator.comparingLong(potentialGroupTitles::get).thenComparingLong(t -> ((String) t).length())) .orElse(e.getKey()); }));
public MigrationExample1(){ /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ //Log.setLevel(ch.qos.logback.classic.Level.WARN); System.out.println("Starting " + getClass().getSimpleName()); simulation = new CloudSim(); @SuppressWarnings("unused") Datacenter datacenter0 = createDatacenter(); broker = new DatacenterBrokerSimple(simulation); createAndSubmitVms(broker); createAndSubmitCloudlets(broker); broker.addOnVmsCreatedListener(this::onVmsCreatedListener); simulation.start(); final List<Cloudlet> finishedList = broker.getCloudletFinishedList(); finishedList.sort( Comparator.comparingLong((Cloudlet c) -> c.getVm().getHost().getId()) .thenComparingLong(c -> c.getVm().getId())); new CloudletsTableBuilder(finishedList).build(); System.out.println("\nHosts CPU usage History (when the allocated MIPS is lower than the requested, it is due to VM migration overhead)"); hostList.stream().filter(h -> h.getId() <= 2).forEach(this::printHostHistory); System.out.println(getClass().getSimpleName() + " finished!"); }
public MigrationExample2_PowerUsage(){ /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ //Log.setLevel(ch.qos.logback.classic.Level.WARN); System.out.println("Starting " + getClass().getSimpleName()); simulation = new CloudSim(); @SuppressWarnings("unused") Datacenter datacenter0 = createDatacenter(); DatacenterBroker broker = new DatacenterBrokerSimple(simulation); createAndSubmitVms(broker); createAndSubmitCloudlets(broker); simulation.start(); final List<Cloudlet> finishedList = broker.getCloudletFinishedList(); finishedList.sort( Comparator.comparingLong((Cloudlet c) -> c.getVm().getHost().getId()) .thenComparingLong(c -> c.getVm().getId())); new CloudletsTableBuilder(finishedList).build(); System.out.println("\n WHEN A HOST CPU ALLOCATED MIPS IS LOWER THAN THE REQUESTED, IT'S DUE TO VM MIGRATION OVERHEAD)\n"); hostList.stream().forEach(this::printHistory); System.out.println(getClass().getSimpleName() + " finished!"); }
public DynamicVmAllocationPolicyBestFitExample(){ /*Enables just some level of log messages. Make sure to import org.cloudsimplus.util.Log;*/ //Log.setLevel(ch.qos.logback.classic.Level.WARN); System.out.println("Starting " + getClass().getSimpleName()); simulation = new CloudSim(); @SuppressWarnings("unused") Datacenter datacenter0 = createDatacenter(); DatacenterBroker broker = new DatacenterBrokerSimple(simulation); createAndSubmitVms(broker); createAndSubmitCloudlets(broker); simulation.start(); final List<Cloudlet> finishedList = broker.getCloudletFinishedList(); finishedList.sort( Comparator.comparingLong((Cloudlet c) -> c.getVm().getHost().getId()) .thenComparingLong(c -> c.getVm().getId())); new CloudletsTableBuilder(finishedList).build(); System.out.println(getClass().getSimpleName() + " finished!"); }
processInstance.getDeploymentId()); processNodes = summary.getProcessDefinition().getNodes().stream().sorted(comparing(ProcessNodeSummary::getName, String.CASE_INSENSITIVE_ORDER).thenComparingLong(ProcessNodeSummary::getId)).collect(toList()); nodeInstances = summary.getNodeInstances().stream().sorted(comparing(NodeInstanceSummary::getName, String.CASE_INSENSITIVE_ORDER).thenComparingLong(NodeInstanceSummary::getId)).collect(toList()); timerInstances = summary.getTimerInstances().stream().sorted(comparing(TimerInstanceSummary::getName, String.CASE_INSENSITIVE_ORDER).thenComparingLong(TimerInstanceSummary::getId)).collect(toList());
.reversed() .thenComparing(n -> n.getPrefix().getStartIp()) .thenComparingLong(OspfNetwork::getArea), proc.getNetworks());