本文整理了Java中java.lang.Integer.max()
方法的一些代码示例,展示了Integer.max()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Integer.max()
方法的具体详情如下:
包路径:java.lang.Integer
类名称:Integer
方法名:max
暂无
代码示例来源:origin: prestodb/presto
private static int rescaleFactor(long fromScale, long toScale)
{
return max(0, (int) toScale - (int) fromScale);
}
代码示例来源:origin: neo4j/neo4j
public void increment( int typeId )
{
if ( typeId >= counts.length )
{
counts = Arrays.copyOf( counts, max( counts.length * 2, typeId + 1 ) );
}
counts[typeId]++;
if ( typeId > highestTypeId )
{
highestTypeId = typeId;
}
}
代码示例来源:origin: neo4j/neo4j
@Override
public int processors( int delta )
{
targetNumberOfProcessors = max( 1, min( targetNumberOfProcessors + delta, maxProcessors ) );
return targetNumberOfProcessors;
}
代码示例来源:origin: neo4j/neo4j
private static int highestLabelId( Labels[] data )
{
int highest = 0;
for ( Labels labels : data )
{
highest = Integer.max( highest, labels.labelId );
}
return highest;
}
代码示例来源:origin: Graylog2/graylog2-server
/**
* Ensures that an integer is within a given range.
*
* @param i The number to check.
* @param min The minimum value to return.
* @param max The maximum value to return.
* @return {@code i} if the number is between {@code min} and {@code max},
* {@code min} if {@code i} is less than the minimum,
* {@code max} if {@code i} is greater than the maximum.
*/
private static int intRange(int i, int min, int max) {
return Integer.min(Integer.max(min, i), max);
}
代码示例来源:origin: neo4j/neo4j
private synchronized void closeClient()
{
if ( --opened == 0 )
{
int highestTypeId = 0;
for ( Client client : clients )
{
highestTypeId = max( highestTypeId, client.highestTypeId );
}
long[] counts = new long[highestTypeId + 1];
for ( Client client : clients )
{
client.addTo( counts );
}
typeCounts = new RelationshipTypeCount[counts.length];
for ( int i = 0; i < counts.length; i++ )
{
typeCounts[i] = new RelationshipTypeCount( i, counts[i] );
}
Arrays.sort( typeCounts );
}
}
代码示例来源:origin: prestodb/presto
private Number getLowerBound(double error, List<? extends Number> rows, double percentile)
{
int medianIndex = (int) (rows.size() * percentile);
int marginOfError = (int) (rows.size() * error / 2);
return rows.get(max(medianIndex - marginOfError, 0));
}
代码示例来源:origin: neo4j/neo4j
requestedNumber = max( 1, requestedNumber );
if ( requestedNumber < processors.length )
代码示例来源:origin: neo4j/neo4j
@Override
public int processors( int delta )
{
if ( delta > 0 )
{
numberOfProcessors = min( numberOfProcessors + delta, maxProcessors );
}
else if ( delta < 0 )
{
numberOfProcessors = max( 1, numberOfProcessors + delta );
}
return numberOfProcessors;
}
代码示例来源:origin: knowm/XChange
int rlen = min(max(segLen, r.length), r.length);
int oversize = r.length - segLen;
System.arraycopy(
代码示例来源:origin: apache/storm
result.put("slotsUsed", supervisorSummary.get_num_used_workers());
result.put("slotsFree",
Integer.max(supervisorSummary.get_num_workers()
- supervisorSummary.get_num_used_workers(), 0));
Map<String, Double> totalResources = supervisorSummary.get_total_resources();
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldAddLabels() throws Exception
{
// GIVEN
ControlledInserter inserter = new ControlledInserter();
long[] expected = new long[NODE_COUNT];
try ( NativeLabelScanWriter writer = new NativeLabelScanWriter( max( 5, NODE_COUNT / 100 ), NativeLabelScanWriter.EMPTY ) )
{
writer.initialize( inserter );
// WHEN
for ( int i = 0; i < NODE_COUNT * 3; i++ )
{
NodeLabelUpdate update = randomUpdate( expected );
writer.write( update );
}
}
// THEN
for ( int i = 0; i < LABEL_COUNT; i++ )
{
long[] expectedNodeIds = nodesWithLabel( expected, i );
long[] actualNodeIds = asArray( new LabelScanValueIterator( inserter.nodesFor( i ), new ArrayList<>(), NO_ID ) );
assertArrayEquals( "For label " + i, expectedNodeIds, actualNodeIds );
}
}
代码示例来源:origin: jamesagnew/hapi-fhir
private void addComment(ST tmplt, ElementDefinition ed) {
if(withComments && ed.hasShort() && !ed.getId().startsWith("Extension.")) {
int nspaces;
char[] sep;
nspaces = Integer.max(COMMENT_COL - tmplt.add("comment", "#").render().indexOf('#'), MIN_COMMENT_SEP);
tmplt.remove("comment");
sep = new char[nspaces];
Arrays.fill(sep, ' ');
ArrayList<String> comment_lines = split_text(ed.getShort().replace("\n", " "), MAX_CHARS);
StringBuilder comment = new StringBuilder("# ");
char[] indent = new char[COMMENT_COL];
Arrays.fill(indent, ' ');
for(int i = 0; i < comment_lines.size();) {
comment.append(comment_lines.get(i++));
if(i < comment_lines.size())
comment.append("\n" + new String(indent) + "# ");
}
tmplt.add("comment", new String(sep) + comment.toString());
} else {
tmplt.add("comment", " ");
}
}
代码示例来源:origin: org.neo4j/neo4j-kernel
public void increment( int typeId )
{
if ( typeId >= counts.length )
{
counts = Arrays.copyOf( counts, max( counts.length * 2, typeId + 1 ) );
}
counts[typeId]++;
if ( typeId > highestTypeId )
{
highestTypeId = typeId;
}
}
代码示例来源:origin: andstatus/andstatus
private void removeDuplicatesWithOlder(TimelinePage<T> page, int indExistingPage) {
for (int ind = Integer.max(indExistingPage, 0); ind < pages.size(); ind++) {
pages.get(ind).items.removeAll(page.items);
}
}
代码示例来源:origin: strimzi/strimzi-kafka-operator
private int computePadding(String gunk, Map<String, Property> properties) {
int maxLen = 0;
for (Map.Entry<String, Property> entry: properties.entrySet()) {
maxLen = max(maxLen, entry.getKey().length() + 1 + gunk.length());
}
return maxLen;
}
代码示例来源:origin: org.neo4j/neo4j-kernel
@Override
public int processors( int delta )
{
targetNumberOfProcessors = max( 1, min( targetNumberOfProcessors + delta, maxProcessors ) );
return targetNumberOfProcessors;
}
代码示例来源:origin: org.apache.atlas/atlas-repository
PaginationHelper(Collection<T> items, int offset, int limit) {
Objects.requireNonNull(items, "items can't be empty/null");
this.items = new ArrayList<>(items);
this.maxSize = items.size();
// If limit is negative then limit is effectively the maxSize, else the smaller one out of limit and maxSize
int adjustedLimit = limit < 0 ? maxSize : Integer.min(maxSize, limit);
// Page starting can only be between zero and adjustedLimit
pageStart = Integer.max(0, offset);
// Page end can't exceed the maxSize
pageEnd = Integer.min(adjustedLimit + pageStart, maxSize);
}
代码示例来源:origin: io.prestosql/presto-main
private Number getLowerBound(double error, List<? extends Number> rows, double percentile)
{
int medianIndex = (int) (rows.size() * percentile);
int marginOfError = (int) (rows.size() * error / 2);
return rows.get(max(medianIndex - marginOfError, 0));
}
代码示例来源:origin: org.nuxeo.elasticsearch/nuxeo-elasticsearch-audit
@Override
public int getApplicationStartedOrder() {
int elasticOrder = ((DefaultComponent) Framework.getRuntime().getComponent(
"org.nuxeo.elasticsearch.ElasticSearchComponent")).getApplicationStartedOrder();
int uidgenOrder = ((DefaultComponent) Framework.getRuntime().getComponent(
"org.nuxeo.ecm.core.uidgen.UIDGeneratorService")).getApplicationStartedOrder();
return Integer.max(elasticOrder, uidgenOrder) + 1;
}
内容来源于网络,如有侵权,请联系作者删除!