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

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

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

Comparator.comparingInt介绍

暂无

代码示例

代码示例来源:origin: codecentric/spring-boot-admin

public static Comparator<String> severity() {
  return Comparator.comparingInt(STATUS_ORDER::indexOf);
}

代码示例来源:origin: google/error-prone

private static Comparator<MethodTree> comparingPositions() {
 return comparingInt(InconsistentOverloads::getStartPosition);
}

代码示例来源:origin: google/error-prone

private static Comparator<MethodTree> comparingArity() {
 return comparingInt(ParameterTrie::getMethodTreeArity);
}

代码示例来源:origin: skylot/jadx

public void finish() {
  list.sort(Comparator.comparingInt(ResourceEntry::getId));
}

代码示例来源:origin: skylot/jadx

private static List<MethodNode> sortMethodsByLine(List<MethodNode> methods) {
  List<MethodNode> out = new ArrayList<>(methods);
  out.sort(Comparator.comparingInt(LineAttrNode::getSourceLine));
  return out;
}

代码示例来源:origin: skylot/jadx

public ResourceEntry getByRef(int refId) {
  ResourceEntry key = new ResourceEntry(refId);
  int index = Collections.binarySearch(list, key, Comparator.comparingInt(ResourceEntry::getId));
  if (index < 0) {
    return null;
  }
  return list.get(index);
}

代码示例来源:origin: google/error-prone

public ParameterTrieExtender(MethodTree methodTree) {
 this.methodTree = methodTree;
 this.inputParameters = new TreeSet<>(comparingInt(Parameter::position));
 this.outputParameters = new ArrayList<>();
}

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

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

代码示例来源:origin: MovingBlocks/Terasology

public FacetLayerPreview(WorldGenerator worldGenerator, List<FacetLayer> facetLayers) {
  this.worldGenerator = worldGenerator;
  this.facetLayers = facetLayers.stream()
      .sorted(Comparator.comparingInt(layer -> layer.getClass().getAnnotation(Renders.class).order()))
      .collect(Collectors.toList());
}

代码示例来源:origin: SonarSource/sonarqube

private static List<Map.Entry<String, MetricStatsInt>> fiveBiggest(DistributedMetricStatsInt distributedMetricStatsInt, ToIntFunction<MetricStatsInt> biggerCriteria) {
 Comparator<Map.Entry<String, MetricStatsInt>> comparator = Comparator.comparingInt(a -> biggerCriteria.applyAsInt(a.getValue()));
 return distributedMetricStatsInt.getForLabels()
  .entrySet()
  .stream()
  .sorted(comparator.reversed())
  .limit(5)
  .collect(MoreCollectors.toList(5));
}

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

private static ConstraintSemantics loadConstraintSemantics()
{
  Iterable<ConstraintSemantics> semantics = Service.load( ConstraintSemantics.class );
  List<ConstraintSemantics> candidates = Iterables.asList( semantics );
  checkState( !candidates.isEmpty(), format( "At least one implementation of %s should be available.", ConstraintSemantics.class ) );
  return Collections.max( candidates, Comparator.comparingInt( ConstraintSemantics::getPriority ) );
}

代码示例来源:origin: google/error-prone

@Override
 public Description report(
   Set<MethodTree> affectedTrees, SuggestedFix fix, VisitorState state, BugChecker checker) {
  return affectedTrees.stream()
    .min(Comparator.comparingInt(t -> ((JCTree) t).getStartPosition()))
    .map(t -> checker.describeMatch(t.getModifiers(), fix))
    .orElse(NO_MATCH);
 }
},

代码示例来源:origin: apache/incubator-druid

@JsonCreator
public CustomTierSelectorStrategy(
  @JacksonInject ServerSelectorStrategy serverSelectorStrategy,
  @JacksonInject CustomTierSelectorStrategyConfig config
)
{
 super(serverSelectorStrategy);
 final Map<Integer, Integer> lookup = new HashMap<>();
 int pos = 0;
 for (Integer integer : config.getPriorities()) {
  lookup.put(integer, pos);
  pos++;
 }
 this.comparator = Comparator.comparingInt(lookup::get);
}

代码示例来源:origin: lets-blade/blade

/**
 * Find all in after of the hooks
 *
 * @param path request path
 */
public List<Route> getAfter(String path) {
  String cleanPath = parsePath(path);
  List<Route> afters = hooks.values().stream()
      .flatMap(Collection::stream)
      .sorted(Comparator.comparingInt(Route::getSort))
      .filter(route -> route.getHttpMethod() == HttpMethod.AFTER && matchesPath(route.getPath(), cleanPath))
      .collect(Collectors.toList());
  this.giveMatch(path, afters);
  return afters;
}

代码示例来源:origin: lets-blade/blade

/**
 * Find all in before of the hook
 *
 * @param path request path
 */
public List<Route> getBefore(String path) {
  String cleanPath = parsePath(path);
  List<Route> collect = hooks.values().stream()
      .flatMap(Collection::stream)
      .sorted(Comparator.comparingInt(Route::getSort))
      .filter(route -> route.getHttpMethod() == HttpMethod.BEFORE && matchesPath(route.getPath(), cleanPath))
      .collect(Collectors.toList());
  this.giveMatch(path, collect);
  return collect;
}

代码示例来源:origin: Graylog2/graylog2-server

public Set<ContentPack> loadAllLatest() {
  final Set<ContentPack> allContentPacks = loadAll();
  final ImmutableMultimap.Builder<ModelId, ContentPack> byIdBuilder = ImmutableMultimap.builder();
  for (ContentPack contentPack : allContentPacks) {
    byIdBuilder.put(contentPack.id(), contentPack);
  }
  final ImmutableMultimap<ModelId, ContentPack> contentPacksById = byIdBuilder.build();
  final ImmutableSet.Builder<ContentPack> latestContentPacks = ImmutableSet.builderWithExpectedSize(contentPacksById.keySet().size());
  for (ModelId id : contentPacksById.keySet()) {
    final ImmutableCollection<ContentPack> contentPacks = contentPacksById.get(id);
    final ContentPack latestContentPackRevision = Collections.max(contentPacks, Comparator.comparingInt(Revisioned::revision));
    latestContentPacks.add(latestContentPackRevision);
  }
  return latestContentPacks.build();
}

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

public static QueryExecutionEngine initialize( Dependencies deps, GraphDatabaseAPI graphAPI,
    Iterable<QueryEngineProvider> providers )
{
  List<QueryEngineProvider> engineProviders = asList( providers );
  engineProviders.sort( Comparator.comparingInt( QueryEngineProvider::enginePriority ) );
  QueryEngineProvider provider = Iterables.firstOrNull( engineProviders );
  if ( provider == null )
  {
    return noEngine();
  }
  QueryExecutionEngine engine = provider.createEngine( deps, graphAPI );
  return deps.satisfyDependency( engine );
}

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

public Stages latestStagesInRunOrder() {
    Stages latestRunStages = new Stages();
    for (Stage  stage: this) {
      if(stage.isLatestRun()) {
        latestRunStages.add(stage);
      }
    }
    latestRunStages.sort(Comparator.comparingInt(Stage::getOrderId));
    return latestRunStages;
  }
}

代码示例来源:origin: prestodb/presto

@Test(timeOut = 5000)
public void testMergeSortedEmptyStreamsWithFinishedOnly()
{
  List<ProcessState<Integer>> firstStream = ImmutableList.of(
      ProcessState.finished());
  List<ProcessState<Integer>> secondStream = ImmutableList.of(
      ProcessState.finished());
  WorkProcessor<Integer> mergedStream = WorkProcessorUtils.mergeSorted(
      ImmutableList.of(processorFrom(firstStream), processorFrom(secondStream)),
      Comparator.comparingInt(firstInteger -> firstInteger));
  // before
  assertFalse(mergedStream.isBlocked());
  assertFalse(mergedStream.isFinished());
  assertFinishes(mergedStream);
}

代码示例来源:origin: SonarSource/sonarqube

private String printStatusesAndTypes(@Nullable Set<NodeHealth> nodeHealths) {
 if (nodeHealths == null) {
  return "<null>";
 }
 return nodeHealths.stream()
  // sort by type then status for debugging convenience
  .sorted(Comparator.<NodeHealth>comparingInt(s1 -> s1.getDetails().getType().ordinal())
   .thenComparingInt(s -> s.getStatus().ordinal()))
  .map(s -> ImmutableList.of(s.getDetails().getType().name(), s.getStatus().name()))
  .map(String::valueOf)
  .collect(Collectors.joining(","));
}

相关文章