java.lang.Integer.max()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(201)

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

Integer.max介绍

暂无

代码示例

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

  1. private static int rescaleFactor(long fromScale, long toScale)
  2. {
  3. return max(0, (int) toScale - (int) fromScale);
  4. }

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

  1. public void increment( int typeId )
  2. {
  3. if ( typeId >= counts.length )
  4. {
  5. counts = Arrays.copyOf( counts, max( counts.length * 2, typeId + 1 ) );
  6. }
  7. counts[typeId]++;
  8. if ( typeId > highestTypeId )
  9. {
  10. highestTypeId = typeId;
  11. }
  12. }

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

  1. @Override
  2. public int processors( int delta )
  3. {
  4. targetNumberOfProcessors = max( 1, min( targetNumberOfProcessors + delta, maxProcessors ) );
  5. return targetNumberOfProcessors;
  6. }

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

  1. private static int highestLabelId( Labels[] data )
  2. {
  3. int highest = 0;
  4. for ( Labels labels : data )
  5. {
  6. highest = Integer.max( highest, labels.labelId );
  7. }
  8. return highest;
  9. }

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

  1. /**
  2. * Ensures that an integer is within a given range.
  3. *
  4. * @param i The number to check.
  5. * @param min The minimum value to return.
  6. * @param max The maximum value to return.
  7. * @return {@code i} if the number is between {@code min} and {@code max},
  8. * {@code min} if {@code i} is less than the minimum,
  9. * {@code max} if {@code i} is greater than the maximum.
  10. */
  11. private static int intRange(int i, int min, int max) {
  12. return Integer.min(Integer.max(min, i), max);
  13. }

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

  1. private synchronized void closeClient()
  2. {
  3. if ( --opened == 0 )
  4. {
  5. int highestTypeId = 0;
  6. for ( Client client : clients )
  7. {
  8. highestTypeId = max( highestTypeId, client.highestTypeId );
  9. }
  10. long[] counts = new long[highestTypeId + 1];
  11. for ( Client client : clients )
  12. {
  13. client.addTo( counts );
  14. }
  15. typeCounts = new RelationshipTypeCount[counts.length];
  16. for ( int i = 0; i < counts.length; i++ )
  17. {
  18. typeCounts[i] = new RelationshipTypeCount( i, counts[i] );
  19. }
  20. Arrays.sort( typeCounts );
  21. }
  22. }

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

  1. private Number getLowerBound(double error, List<? extends Number> rows, double percentile)
  2. {
  3. int medianIndex = (int) (rows.size() * percentile);
  4. int marginOfError = (int) (rows.size() * error / 2);
  5. return rows.get(max(medianIndex - marginOfError, 0));
  6. }

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

  1. requestedNumber = max( 1, requestedNumber );
  2. if ( requestedNumber < processors.length )

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

  1. @Override
  2. public int processors( int delta )
  3. {
  4. if ( delta > 0 )
  5. {
  6. numberOfProcessors = min( numberOfProcessors + delta, maxProcessors );
  7. }
  8. else if ( delta < 0 )
  9. {
  10. numberOfProcessors = max( 1, numberOfProcessors + delta );
  11. }
  12. return numberOfProcessors;
  13. }

代码示例来源:origin: knowm/XChange

  1. int rlen = min(max(segLen, r.length), r.length);
  2. int oversize = r.length - segLen;
  3. System.arraycopy(

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

  1. result.put("slotsUsed", supervisorSummary.get_num_used_workers());
  2. result.put("slotsFree",
  3. Integer.max(supervisorSummary.get_num_workers()
  4. - supervisorSummary.get_num_used_workers(), 0));
  5. Map<String, Double> totalResources = supervisorSummary.get_total_resources();

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

  1. @Test
  2. public void shouldAddLabels() throws Exception
  3. {
  4. // GIVEN
  5. ControlledInserter inserter = new ControlledInserter();
  6. long[] expected = new long[NODE_COUNT];
  7. try ( NativeLabelScanWriter writer = new NativeLabelScanWriter( max( 5, NODE_COUNT / 100 ), NativeLabelScanWriter.EMPTY ) )
  8. {
  9. writer.initialize( inserter );
  10. // WHEN
  11. for ( int i = 0; i < NODE_COUNT * 3; i++ )
  12. {
  13. NodeLabelUpdate update = randomUpdate( expected );
  14. writer.write( update );
  15. }
  16. }
  17. // THEN
  18. for ( int i = 0; i < LABEL_COUNT; i++ )
  19. {
  20. long[] expectedNodeIds = nodesWithLabel( expected, i );
  21. long[] actualNodeIds = asArray( new LabelScanValueIterator( inserter.nodesFor( i ), new ArrayList<>(), NO_ID ) );
  22. assertArrayEquals( "For label " + i, expectedNodeIds, actualNodeIds );
  23. }
  24. }

代码示例来源:origin: jamesagnew/hapi-fhir

  1. private void addComment(ST tmplt, ElementDefinition ed) {
  2. if(withComments && ed.hasShort() && !ed.getId().startsWith("Extension.")) {
  3. int nspaces;
  4. char[] sep;
  5. nspaces = Integer.max(COMMENT_COL - tmplt.add("comment", "#").render().indexOf('#'), MIN_COMMENT_SEP);
  6. tmplt.remove("comment");
  7. sep = new char[nspaces];
  8. Arrays.fill(sep, ' ');
  9. ArrayList<String> comment_lines = split_text(ed.getShort().replace("\n", " "), MAX_CHARS);
  10. StringBuilder comment = new StringBuilder("# ");
  11. char[] indent = new char[COMMENT_COL];
  12. Arrays.fill(indent, ' ');
  13. for(int i = 0; i < comment_lines.size();) {
  14. comment.append(comment_lines.get(i++));
  15. if(i < comment_lines.size())
  16. comment.append("\n" + new String(indent) + "# ");
  17. }
  18. tmplt.add("comment", new String(sep) + comment.toString());
  19. } else {
  20. tmplt.add("comment", " ");
  21. }
  22. }

代码示例来源:origin: org.neo4j/neo4j-kernel

  1. public void increment( int typeId )
  2. {
  3. if ( typeId >= counts.length )
  4. {
  5. counts = Arrays.copyOf( counts, max( counts.length * 2, typeId + 1 ) );
  6. }
  7. counts[typeId]++;
  8. if ( typeId > highestTypeId )
  9. {
  10. highestTypeId = typeId;
  11. }
  12. }

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

  1. private void removeDuplicatesWithOlder(TimelinePage<T> page, int indExistingPage) {
  2. for (int ind = Integer.max(indExistingPage, 0); ind < pages.size(); ind++) {
  3. pages.get(ind).items.removeAll(page.items);
  4. }
  5. }

代码示例来源:origin: strimzi/strimzi-kafka-operator

  1. private int computePadding(String gunk, Map<String, Property> properties) {
  2. int maxLen = 0;
  3. for (Map.Entry<String, Property> entry: properties.entrySet()) {
  4. maxLen = max(maxLen, entry.getKey().length() + 1 + gunk.length());
  5. }
  6. return maxLen;
  7. }

代码示例来源:origin: org.neo4j/neo4j-kernel

  1. @Override
  2. public int processors( int delta )
  3. {
  4. targetNumberOfProcessors = max( 1, min( targetNumberOfProcessors + delta, maxProcessors ) );
  5. return targetNumberOfProcessors;
  6. }

代码示例来源:origin: org.apache.atlas/atlas-repository

  1. PaginationHelper(Collection<T> items, int offset, int limit) {
  2. Objects.requireNonNull(items, "items can't be empty/null");
  3. this.items = new ArrayList<>(items);
  4. this.maxSize = items.size();
  5. // If limit is negative then limit is effectively the maxSize, else the smaller one out of limit and maxSize
  6. int adjustedLimit = limit < 0 ? maxSize : Integer.min(maxSize, limit);
  7. // Page starting can only be between zero and adjustedLimit
  8. pageStart = Integer.max(0, offset);
  9. // Page end can't exceed the maxSize
  10. pageEnd = Integer.min(adjustedLimit + pageStart, maxSize);
  11. }

代码示例来源:origin: io.prestosql/presto-main

  1. private Number getLowerBound(double error, List<? extends Number> rows, double percentile)
  2. {
  3. int medianIndex = (int) (rows.size() * percentile);
  4. int marginOfError = (int) (rows.size() * error / 2);
  5. return rows.get(max(medianIndex - marginOfError, 0));
  6. }

代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-audit

  1. @Override
  2. public int getApplicationStartedOrder() {
  3. int elasticOrder = ((DefaultComponent) Framework.getRuntime().getComponent(
  4. "org.nuxeo.elasticsearch.ElasticSearchComponent")).getApplicationStartedOrder();
  5. int uidgenOrder = ((DefaultComponent) Framework.getRuntime().getComponent(
  6. "org.nuxeo.ecm.core.uidgen.UIDGeneratorService")).getApplicationStartedOrder();
  7. return Integer.max(elasticOrder, uidgenOrder) + 1;
  8. }

相关文章