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

How to use
max
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.max (Showing top 20 results out of 96,165)

origin: stackoverflow.com

 jQuery.fn.center = function () {
  this.css("position","absolute");
  this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + 
                        $(window).scrollTop()) + "px");
  this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + 
                        $(window).scrollLeft()) + "px");
  return this;
}
origin: ReactiveX/RxJava

public ObservableConcatMap(ObservableSource<T> source, Function<? super T, ? extends ObservableSource<? extends U>> mapper,
    int bufferSize, ErrorMode delayErrors) {
  super(source);
  this.mapper = mapper;
  this.delayErrors = delayErrors;
  this.bufferSize = Math.max(8, bufferSize);
}
origin: google/guava

long longSize() {
 Segment<K, V>[] segments = this.segments;
 long sum = 0;
 for (int i = 0; i < segments.length; ++i) {
  sum += Math.max(0, segments[i].count); // see https://github.com/google/guava/issues/2108
 }
 return sum;
}
origin: google/guava

 @Override
 public int size() {
  return Math.max(0, super.size() + delta);
 }
};
origin: google/guava

static int closedTableSize(int expectedEntries, double loadFactor) {
 // Get the recommended table size.
 // Round down to the nearest power of 2.
 expectedEntries = Math.max(expectedEntries, 2);
 int tableSize = Integer.highestOneBit(expectedEntries);
 // Check to make sure that we will not exceed the maximum load factor.
 if (expectedEntries > (int) (loadFactor * tableSize)) {
  tableSize <<= 1;
  return (tableSize > 0) ? tableSize : MAX_TABLE_SIZE;
 }
 return tableSize;
}
origin: ReactiveX/RxJava

MergeSubscriber(Subscriber<? super U> actual, Function<? super T, ? extends Publisher<? extends U>> mapper,
    boolean delayErrors, int maxConcurrency, int bufferSize) {
  this.downstream = actual;
  this.mapper = mapper;
  this.delayErrors = delayErrors;
  this.maxConcurrency = maxConcurrency;
  this.bufferSize = bufferSize;
  this.scalarLimit = Math.max(1, maxConcurrency >> 1);
  subscribers.lazySet(EMPTY);
}
origin: google/guava

private AvlNode<E> addRightChild(E e, int count) {
 right = new AvlNode<E>(e, count);
 successor(this, right, succ);
 height = Math.max(2, height);
 distinctElements++;
 totalCount += count;
 return this;
}
origin: google/guava

private AvlNode<E> addLeftChild(E e, int count) {
 left = new AvlNode<E>(e, count);
 successor(pred, left, this);
 height = Math.max(2, height);
 distinctElements++;
 totalCount += count;
 return this;
}
origin: google/guava

/**
 * Reserves next ticket and returns the wait time that the caller must wait for.
 *
 * @return the required wait time, never negative
 */
final long reserveAndGetWaitLength(int permits, long nowMicros) {
 long momentAvailable = reserveEarliestAvailable(permits, nowMicros);
 return max(momentAvailable - nowMicros, 0);
}
origin: google/guava

 @Override
 protected Set<String> create(String[] elements) {
  ImmutableSet.Builder<String> builder =
    ImmutableSet.builderWithExpectedSize(Math.max(0, Sets.newHashSet(elements).size() - 1));
  for (String e : elements) {
   builder.add(e);
  }
  return builder.build();
 }
}
origin: google/guava

@Override
int maxEncodedSize(int bytes) {
 int unseparatedSize = delegate.maxEncodedSize(bytes);
 return unseparatedSize
   + separator.length() * divide(Math.max(0, unseparatedSize - 1), afterEveryChars, FLOOR);
}
origin: google/guava

/** Pseudoconstructor for serialization support. */
void init(int expectedSize, float loadFactor) {
 Preconditions.checkArgument(expectedSize >= 0, "Initial capacity must be non-negative");
 Preconditions.checkArgument(loadFactor > 0, "Illegal load factor");
 int buckets = Hashing.closedTableSize(expectedSize, loadFactor);
 this.table = newTable(buckets);
 this.loadFactor = loadFactor;
 this.elements = new Object[expectedSize];
 this.entries = newEntries(expectedSize);
 this.threshold = Math.max(1, (int) (buckets * loadFactor));
}
origin: ReactiveX/RxJava

public SpscLinkedArrayQueue(final int bufferSize) {
  int p2capacity = Pow2.roundToPowerOfTwo(Math.max(8, bufferSize));
  int mask = p2capacity - 1;
  AtomicReferenceArray<Object> buffer = new AtomicReferenceArray<Object>(p2capacity + 1);
  producerBuffer = buffer;
  producerMask = mask;
  adjustLookAheadStep(p2capacity);
  consumerBuffer = buffer;
  consumerMask = mask;
  producerLookAhead = mask - 1; // we know it's all empty to start with
  soProducerIndex(0L);
}
origin: google/guava

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

 private static long worstCaseQueryOperations(Map<?, ?> map, CallsCounter counter) {
  long worstCalls = 0;
  for (Object k : map.keySet()) {
   counter.zero();
   Object unused = map.get(k);
   worstCalls = Math.max(worstCalls, counter.total());
  }
  return worstCalls;
 }
}
origin: google/guava

private long measureTotalTimeMillis(RateLimiter rateLimiter, int permits, Random random) {
 long startTime = stopwatch.instant;
 while (permits > 0) {
  int nextPermitsToAcquire = Math.max(1, random.nextInt(permits));
  permits -= nextPermitsToAcquire;
  rateLimiter.acquire(nextPermitsToAcquire);
 }
 rateLimiter.acquire(1); // to repay for any pending debt
 return NANOSECONDS.toMillis(stopwatch.instant - startTime);
}
origin: google/guava

@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeysRemove() {
 int original = multimap().keys().remove(k0(), 1);
 assertEquals(Math.max(original - 1, 0), multimap().get(k0()).size());
}
origin: ReactiveX/RxJava

  @Override
  public Publisher<Integer> createPublisher(long elements) {
    return
        Flowable.range(1, Math.max(0, (int)elements - 1))
        .concatWith(Single.just((int)elements))
      ;
  }
}
origin: ReactiveX/RxJava

  @Override
  public Publisher<Integer> createPublisher(long elements) {
    return
        Flowable.range(1, Math.max(0, (int)elements - 1))
        .concatWith(Maybe.just((int)elements))
      ;
  }
}
origin: google/guava

 private static long worstCaseQueryOperations(Multiset<?> multiset, CallsCounter counter) {
  long worstCalls = 0;
  for (Object k : multiset.elementSet()) {
   counter.zero();
   int unused = multiset.count(k);
   worstCalls = Math.max(worstCalls, counter.total());
  }
  return worstCalls;
 }
}
java.langMathmax

Javadoc

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

Special cases:

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

Popular methods of Math

  • min
    Returns the smaller 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 PhpStorm 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