java.util.Comparator.thenComparingLong()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(317)

本文整理了Java中java.util.Comparator.thenComparingLong()方法的一些代码示例,展示了Comparator.thenComparingLong()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Comparator.thenComparingLong()方法的具体详情如下:
包路径:java.util.Comparator
类名称:Comparator
方法名:thenComparingLong

Comparator.thenComparingLong介绍

暂无

代码示例

代码示例来源:origin: speedment/speedment

@Override
public Comparator<ENTITY> thenComparingLong(
    ToLongFunction<? super ENTITY> keyExtractor) {
  return asCombined().thenComparingLong(keyExtractor);
}

代码示例来源:origin: graphhopper/graphhopper

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<>();
}

代码示例来源:origin: apache/accumulo

@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);
 }
}

代码示例来源:origin: apache/accumulo

@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);
 }
}

代码示例来源:origin: kamax-matrix/mxhsd

public static Comparator<IProcessedEvent> forProcessed() {
  return (Comparator<IProcessedEvent>) byPreviousEvents.thenComparingLong(IEvent::getDepth)
      .thenComparing(IEvent::getTimestamp);
}

代码示例来源:origin: kamax-matrix/mxhsd

public static Comparator<IEvent> forEvent() {
  return (Comparator<IEvent>) byPreviousEvents.thenComparingLong(IEvent::getDepth)
      .thenComparing(IEvent::getTimestamp);
}

代码示例来源:origin: Javacord/Javacord

@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()));
}

代码示例来源:origin: Javacord/Javacord

@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()));
}

代码示例来源:origin: Javacord/Javacord

@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()));
}

代码示例来源:origin: com.speedment.runtime/runtime-field

@Override
public Comparator<ENTITY> thenComparingLong(
    ToLongFunction<? super ENTITY> keyExtractor) {
  return asCombined().thenComparingLong(keyExtractor);
}

代码示例来源:origin: Javacord/Javacord

@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);
}

代码示例来源:origin: Javacord/Javacord

@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()));
}

代码示例来源:origin: com.github.tornaia/aott-desktop-client-core

return prefixAndPostfix(title)
      .stream()
      .max(Comparator.comparingLong(potentialGroupTitles::get).thenComparingLong(t -> ((String) t).length()))
      .orElse(e.getKey());
}));

代码示例来源:origin: manoelcampos/cloudsim-plus

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!");
}

代码示例来源:origin: manoelcampos/cloudsim-plus

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!");
}

代码示例来源:origin: manoelcampos/cloudsim-plus

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!");
}

代码示例来源:origin: org.jbpm/jbpm-wb-process-runtime-client

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());

代码示例来源:origin: batfish/batfish

.reversed()
  .thenComparing(n -> n.getPrefix().getStartIp())
  .thenComparingLong(OspfNetwork::getArea),
proc.getNetworks());

相关文章