Tabnine Logo
Math.min
Code IndexAdd Tabnine to your IDE (free)

How to use
min
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.min (Showing top 20 results out of 107,199)

origin: google/guava

@Override
public long padToLong() {
 long retVal = (bytes[0] & 0xFF);
 for (int i = 1; i < Math.min(bytes.length, 8); i++) {
  retVal |= (bytes[i] & 0xFFL) << (i * 8);
 }
 return retVal;
}
origin: google/guava

@Override
public int compare(double[] left, double[] right) {
 int minLength = Math.min(left.length, right.length);
 for (int i = 0; i < minLength; i++) {
  int result = Double.compare(left[i], right[i]);
  if (result != 0) {
   return result;
  }
 }
 return left.length - right.length;
}
origin: google/guava

@Override
public int read(byte[] b, int off, int len) throws IOException {
 if (left == 0) {
  return -1;
 }
 len = (int) Math.min(len, left);
 int result = in.read(b, off, len);
 if (result != -1) {
  left -= result;
 }
 return result;
}
origin: square/okhttp

@Override public void setFixedLengthStreamingMode(long contentLength) {
 if (super.connected) throw new IllegalStateException("Already connected");
 if (chunkLength > 0) throw new IllegalStateException("Already in chunked mode");
 if (contentLength < 0) throw new IllegalArgumentException("contentLength < 0");
 this.fixedContentLength = contentLength;
 super.fixedContentLength = (int) Math.min(contentLength, Integer.MAX_VALUE);
}
origin: google/guava

@Override
public ByteSource slice(long offset, long length) {
 checkArgument(offset >= 0, "offset (%s) may not be negative", offset);
 checkArgument(length >= 0, "length (%s) may not be negative", length);
 offset = Math.min(offset, this.length);
 length = Math.min(length, this.length - offset);
 int newOffset = this.offset + (int) offset;
 return new ByteArrayByteSource(bytes, newOffset, (int) length);
}
origin: square/okhttp

private void encodeBase64Lines(StringBuilder out, ByteString data) {
 String base64 = data.base64();
 for (int i = 0; i < base64.length(); i += 64) {
  out.append(base64, i, Math.min(i + 64, base64.length())).append('\n');
 }
}
origin: google/guava

@Override
public int compare(long[] left, long[] right) {
 int minLength = Math.min(left.length, right.length);
 for (int i = 0; i < minLength; i++) {
  if (left[i] != right[i]) {
   return UnsignedLongs.compare(left[i], right[i]);
  }
 }
 return left.length - right.length;
}
origin: google/guava

@Override
public int compare(int[] left, int[] right) {
 int minLength = Math.min(left.length, right.length);
 for (int i = 0; i < minLength; i++) {
  if (left[i] != right[i]) {
   return UnsignedInts.compare(left[i], right[i]);
  }
 }
 return left.length - right.length;
}
origin: google/guava

/** Returns best-effort-sized StringBuilder based on the given collection size. */
static StringBuilder newStringBuilderForCollection(int size) {
 checkNonnegative(size, "size");
 return new StringBuilder((int) Math.min(size * 8L, Ints.MAX_POWER_OF_TWO));
}
origin: google/guava

@Override
public int compare(int[] left, int[] right) {
 int minLength = Math.min(left.length, right.length);
 for (int i = 0; i < minLength; i++) {
  int result = Ints.compare(left[i], right[i]);
  if (result != 0) {
   return result;
  }
 }
 return left.length - right.length;
}
origin: google/guava

@Override
public int compare(char[] left, char[] right) {
 int minLength = Math.min(left.length, right.length);
 for (int i = 0; i < minLength; i++) {
  int result = Chars.compare(left[i], right[i]);
  if (result != 0) {
   return result;
  }
 }
 return left.length - right.length;
}
origin: ReactiveX/RxJava

public SpscArrayQueue(int capacity) {
  super(Pow2.roundToPowerOfTwo(capacity));
  this.mask = length() - 1;
  this.producerIndex = new AtomicLong();
  this.consumerIndex = new AtomicLong();
  lookAheadStep = Math.min(capacity / 4, MAX_LOOK_AHEAD_STEP);
}
origin: ReactiveX/RxJava

ConcatMapEagerDelayErrorSubscriber(Subscriber<? super R> actual,
    Function<? super T, ? extends Publisher<? extends R>> mapper, int maxConcurrency, int prefetch,
    ErrorMode errorMode) {
  this.downstream = actual;
  this.mapper = mapper;
  this.maxConcurrency = maxConcurrency;
  this.prefetch = prefetch;
  this.errorMode = errorMode;
  this.subscribers = new SpscLinkedArrayQueue<InnerQueuedSubscriber<R>>(Math.min(prefetch, maxConcurrency));
  this.errors = new AtomicThrowable();
  this.requested = new AtomicLong();
}
origin: google/guava

 @Override
 public Spliterator<T> spliterator() {
  if (iterable instanceof List) {
   final List<T> list = (List<T>) iterable;
   int toSkip = Math.min(list.size(), numberToSkip);
   return list.subList(toSkip, list.size()).spliterator();
  } else {
   return Streams.stream(iterable).skip(numberToSkip).spliterator();
  }
 }
};
origin: square/okhttp

@Override public void write(Buffer source, long byteCount) throws IOException {
 long toRead = Math.min(remainingByteCount, byteCount);
 if (toRead > 0) {
  source.read(buffer, toRead);
 }
 long toSkip = byteCount - toRead;
 if (toSkip > 0) {
  source.skip(toSkip);
 }
 remainingByteCount -= toRead;
 receivedByteCount += byteCount;
}
origin: square/okhttp

private void writeContinuationFrames(int streamId, long byteCount) throws IOException {
 while (byteCount > 0) {
  int length = (int) Math.min(maxFrameSize, byteCount);
  byteCount -= length;
  frameHeader(streamId, length, TYPE_CONTINUATION, byteCount == 0 ? FLAG_END_HEADERS : 0);
  sink.write(hpackBuffer, length);
 }
}
origin: google/guava

@Override
public int count(Object element) {
 int count1 = multiset1.count(element);
 return (count1 == 0) ? 0 : Math.min(count1, multiset2.count(element));
}
origin: google/guava

HashIterator() {
 nextSegmentIndex = segments.length - 1;
 nextTableIndex = -1;
 advance();
}
origin: google/guava

 @Override
 public int read(char[] cbuf, int off, int len) throws IOException {
  return super.read(cbuf, off, Math.min(chunk, len));
 }
};
origin: google/guava

public void testEviction_maxSizeOneSegment() {
 IdentityLoader<Integer> loader = identityLoader();
 LoadingCache<Integer, Integer> cache =
   CacheBuilder.newBuilder().concurrencyLevel(1).maximumSize(MAX_SIZE).build(loader);
 for (int i = 0; i < 2 * MAX_SIZE; i++) {
  cache.getUnchecked(i);
  assertEquals(Math.min(i + 1, MAX_SIZE), cache.size());
 }
 assertEquals(MAX_SIZE, cache.size());
 CacheTesting.checkValidState(cache);
}
java.langMathmin

Javadoc

Returns the most negative (closest to negative infinity) of the two arguments.

Special cases:

  • min(NaN, (anything)) = NaN
  • min((anything), NaN) = NaN
  • min(+0.0, -0.0) = -0.0
  • min(-0.0, +0.0) = -0.0

Popular methods of Math

  • max
    Returns the greater of two long values. That is, the result is the argument closer to the value of L
  • abs
    Returns the absolute value of a long value. If the argument is not negative, the argument is returne
  • round
    Returns the closest int to the argument, with ties rounding up. Special cases: * If the argument is
  • pow
    Returns the value of the first argument raised to the power of the second argument. Special cases: *
  • sqrt
    Returns the correctly rounded positive square root of a double value. Special cases: * If the argume
  • ceil
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to th
  • floor
    Returns the largest (closest to positive infinity) double value that is less than or equal to the ar
  • random
    Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returne
  • sin
    Returns the trigonometric sine of an angle. Special cases: * If the argument is NaN or an infinit
  • cos
    Returns the trigonometric cosine of an angle. Special cases: * If the argument is NaN or an infin
  • log
    Returns the natural logarithm (base e) of a doublevalue. Special cases: * If the argument is NaN
  • exp
    Returns Euler's number e raised to the power of a double value. Special cases: * If the argument
  • log,
  • exp,
  • toRadians,
  • atan2,
  • log10,
  • acos,
  • tan,
  • toDegrees,
  • atan

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • getSharedPreferences (Context)
  • onCreateOptionsMenu (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • Menu (java.awt)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • String (java.lang)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Path (java.nio.file)
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now