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

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

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

Comparator.thenComparingDouble介绍

暂无

代码示例

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

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

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

@Override
public void recordEnd(final Traverser.Admin<Object> traverser, final Traversal.Admin<Object, Object> traversal) {
  this.getBundle(traversal).incrementEndCount();
  if (!this.onComputer) {  // if on computer, sort on a per traverser-basis with bias towards local star graph
    if (this.counter < 200 || this.counter % 250 == 0) // aggressively sort for the first 200 results -- after that, sort every 250
      Collections.sort(this.bundles, Comparator.<Bundle>comparingInt(b -> b.traversalType.ordinal()).thenComparingDouble(b -> b.multiplicity));
    this.counter++;
  }
}

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

@Override
public Traversal.Admin<Object, Object> apply(final Traverser.Admin<Object> traverser) {
  // optimization to favor processing StarGraph local objects first to limit message passing (GraphComputer only)
  // TODO: generalize this for future MatchAlgorithms (given that 3.2.0 will focus on RealTimeStrategy, it will probably go there)
  if (this.onComputer) {
    final List<Set<String>> labels = traverser.path().labels();
    final Set<String> lastLabels = labels.get(labels.size() - 1);
    Collections.sort(this.bundles,
        Comparator.<Bundle>comparingLong(b -> Helper.getStartLabels(b.traversal).stream().filter(startLabel -> !lastLabels.contains(startLabel)).count()).
            thenComparingInt(b -> b.traversalType.ordinal()).
            thenComparingDouble(b -> b.multiplicity));
  }
  Bundle startLabelsBundle = null;
  for (final Bundle bundle : this.bundles) {
    if (!Helper.hasExecutedTraversal(traverser, bundle.traversal) && Helper.hasStartLabels(traverser, bundle.traversal)) {
      if (bundle.traversalType != TraversalType.MATCH_TRAVERSAL || Helper.hasEndLabel(traverser, bundle.traversal))
        return bundle.traversal;
      else if (null == startLabelsBundle)
        startLabelsBundle = bundle;
    }
  }
  if (null != startLabelsBundle) return startLabelsBundle.traversal;
  throw UNMATCHABLE_PATTERN.apply(this.bundles.stream().map(record -> record.traversal).collect(Collectors.toList()));
}

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

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

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
public void recordEnd(final Traverser.Admin<Object> traverser, final Traversal.Admin<Object, Object> traversal) {
  this.getBundle(traversal).incrementEndCount();
  if (!this.onComputer) {  // if on computer, sort on a per traverser-basis with bias towards local star graph
    if (this.counter < 200 || this.counter % 250 == 0) // aggressively sort for the first 200 results -- after that, sort every 250
      Collections.sort(this.bundles, Comparator.<Bundle>comparingInt(b -> b.traversalType.ordinal()).thenComparingDouble(b -> b.multiplicity));
    this.counter++;
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
public Traversal.Admin<Object, Object> apply(final Traverser.Admin<Object> traverser) {
  // optimization to favor processing StarGraph local objects first to limit message passing (GraphComputer only)
  // TODO: generalize this for future MatchAlgorithms (given that 3.2.0 will focus on RealTimeStrategy, it will probably go there)
  if (this.onComputer) {
    final List<Set<String>> labels = traverser.path().labels();
    final Set<String> lastLabels = labels.get(labels.size() - 1);
    Collections.sort(this.bundles,
        Comparator.<Bundle>comparingLong(b -> Helper.getStartLabels(b.traversal).stream().filter(startLabel -> !lastLabels.contains(startLabel)).count()).
            thenComparingInt(b -> b.traversalType.ordinal()).
            thenComparingDouble(b -> b.multiplicity));
  }
  Bundle startLabelsBundle = null;
  for (final Bundle bundle : this.bundles) {
    if (!Helper.hasExecutedTraversal(traverser, bundle.traversal) && Helper.hasStartLabels(traverser, bundle.traversal)) {
      if (bundle.traversalType != TraversalType.MATCH_TRAVERSAL || Helper.hasEndLabel(traverser, bundle.traversal))
        return bundle.traversal;
      else if (null == startLabelsBundle)
        startLabelsBundle = bundle;
    }
  }
  if (null != startLabelsBundle) return startLabelsBundle.traversal;
  throw UNMATCHABLE_PATTERN.apply(this.bundles.stream().map(record -> record.traversal).collect(Collectors.toList()));
}

相关文章