當前位置: 首頁>>代碼示例>>Java>>正文


Java IntMath.checkedMultiply方法代碼示例

本文整理匯總了Java中com.google.common.math.IntMath.checkedMultiply方法的典型用法代碼示例。如果您正苦於以下問題:Java IntMath.checkedMultiply方法的具體用法?Java IntMath.checkedMultiply怎麽用?Java IntMath.checkedMultiply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.math.IntMath的用法示例。


在下文中一共展示了IntMath.checkedMultiply方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CartesianList

import com.google.common.math.IntMath; //導入方法依賴的package包/類
CartesianList(ImmutableList<List<E>> axes) {
  this.axes = axes;
  int[] axesSizeProduct = new int[axes.size() + 1];
  axesSizeProduct[axes.size()] = 1;
  try {
    for (int i = axes.size() - 1; i >= 0; i--) {
      axesSizeProduct[i] = IntMath.checkedMultiply(axesSizeProduct[i + 1], axes.get(i).size());
    }
  } catch (ArithmeticException e) {
    throw new IllegalArgumentException(
        "Cartesian product too large; must have size at most Integer.MAX_VALUE");
  }
  this.axesSizeProduct = axesSizeProduct;
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:15,代碼來源:CartesianList.java

示例2: calculateNewCapacity

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
  int oldCapacity = queue.length;
  int newCapacity =
      (oldCapacity < 64)
          ? (oldCapacity + 1) * 2
          : IntMath.checkedMultiply(oldCapacity / 2, 3);
  return capAtMaximumSize(newCapacity, maximumSize);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:10,代碼來源:MinMaxPriorityQueue.java

示例3: create

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * Creates a FilterTable
 * 
 * @param bitsPerTag
 *            number of bits needed for each tag
 * @param numBuckets
 *            number of buckets in filter
 * @return
 */
static FilterTable create(int bitsPerTag, long numBuckets) {
	// why would this ever happen?
	checkArgument(bitsPerTag < 48, "tagBits (%s) should be less than 48 bits", bitsPerTag);
	// shorter fingerprints don't give us a good fill capacity
	checkArgument(bitsPerTag > 4, "tagBits (%s) must be > 4", bitsPerTag);
	checkArgument(numBuckets > 1, "numBuckets (%s) must be > 1", numBuckets);
	// checked so our implementors don't get too.... "enthusiastic" with
	// table size
	long bitsPerBucket = IntMath.checkedMultiply(CuckooFilter.BUCKET_SIZE, bitsPerTag);
	long bitSetSize = LongMath.checkedMultiply(bitsPerBucket, numBuckets);
	LongBitSet memBlock = new LongBitSet(bitSetSize);
	return new FilterTable(memBlock, bitsPerTag, numBuckets);
}
 
開發者ID:MGunlogson,項目名稱:CuckooFilter4J,代碼行數:23,代碼來源:FilterTable.java

示例4: CartesianList

import com.google.common.math.IntMath; //導入方法依賴的package包/類
CartesianList(ImmutableList<List<E>> axes) {
  this.axes = axes;

  int[] axesSizeProduct = new int[axes.size() + 1];
  axesSizeProduct[axes.size()] = 1;
  try {
    for (int i = axes.size() - 1; i >= 0; i--) {
      axesSizeProduct[i] = IntMath.checkedMultiply(axesSizeProduct[i + 1], axes.get(i).size());
    }
  } catch (ArithmeticException e) {
    throw new IllegalArgumentException("Cartesian product too large; must have size at most Integer.MAX_VALUE");
  }
  this.axesSizeProduct = axesSizeProduct;
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:15,代碼來源:CartesianList.java

示例5: calculateNewCapacity

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/** Returns ~2x the old capacity if small; ~1.5x otherwise. */

  private int calculateNewCapacity() {
    int oldCapacity = queue.length;
    int newCapacity = (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
    return capAtMaximumSize(newCapacity, maximumSize);
          }
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:8,代碼來源:MinMaxPriorityQueue.java

示例6: CartesianList

import com.google.common.math.IntMath; //導入方法依賴的package包/類
CartesianList(ImmutableList<List<E>> axes) {
  this.axes = axes;
  int[] axesSizeProduct = new int[axes.size() + 1];
  axesSizeProduct[axes.size()] = 1;
  try {
    for (int i = axes.size() - 1; i >= 0; i--) {
      axesSizeProduct[i] =
          IntMath.checkedMultiply(axesSizeProduct[i + 1], axes.get(i).size());
    }
  } catch (ArithmeticException e) {
    throw new IllegalArgumentException(
        "Cartesian product too large; must have size at most Integer.MAX_VALUE");
  }
  this.axesSizeProduct = axesSizeProduct;
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:16,代碼來源:CartesianList.java

示例7: calculateNewCapacity

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
  int oldCapacity = queue.length;
  int newCapacity = (oldCapacity < 64)
      ? (oldCapacity + 1) * 2
      : IntMath.checkedMultiply(oldCapacity / 2, 3);
  return capAtMaximumSize(newCapacity, maximumSize);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:9,代碼來源:MinMaxPriorityQueue.java

示例8: noMulOverflow

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override
public boolean noMulOverflow(int a, int b) {
  try {
    IntMath.checkedMultiply(a, b);
    return true;
  } catch (ArithmeticException e) {
    return false;
  }
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:10,代碼來源:ApacheBenchmark.java

示例9: CartesianSet

import com.google.common.math.IntMath; //導入方法依賴的package包/類
CartesianSet(List<? extends Set<? extends B>> sets) {
  int dividend = 1;
  ImmutableList.Builder<Axis> builder = ImmutableList.builder();
  try {
    for (Set<? extends B> set : sets) {
      Axis axis = new Axis(set, dividend);
      builder.add(axis);
      dividend = IntMath.checkedMultiply(dividend, axis.size());
    }
  } catch (ArithmeticException overflow) {
    throw new IllegalArgumentException("cartesian product too big");
  }
  this.axes = builder.build();
  size = dividend;
}
 
開發者ID:10xEngineer,項目名稱:My-Wallet-Android,代碼行數:16,代碼來源:Sets.java

示例10: binop

import com.google.common.math.IntMath; //導入方法依賴的package包/類
static Integer binop(Kind kind, int lhs, int rhs) {
  switch (kind) {
    case MULTIPLY:
      return IntMath.checkedMultiply(lhs, rhs);
    case DIVIDE:
      return lhs / rhs;
    case REMAINDER:
      return lhs % rhs;
    case PLUS:
      return IntMath.checkedAdd(lhs, rhs);
    case MINUS:
      return IntMath.checkedSubtract(lhs, rhs);
    case LEFT_SHIFT:
      return lhs << rhs;
    case RIGHT_SHIFT:
      return lhs >> rhs;
    case UNSIGNED_RIGHT_SHIFT:
      return lhs >>> rhs;
    case AND:
      return lhs & rhs;
    case XOR:
      return lhs ^ rhs;
    case OR:
      return lhs | rhs;
    default:
      return null;
  }
}
 
開發者ID:google,項目名稱:error-prone,代碼行數:29,代碼來源:ConstantOverflow.java

示例11: calculateNewCapacity

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
  int oldCapacity = queue.length;
  int newCapacity =
      (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
  return capAtMaximumSize(newCapacity, maximumSize);
}
 
開發者ID:google,項目名稱:guava,代碼行數:8,代碼來源:MinMaxPriorityQueue.java


注:本文中的com.google.common.math.IntMath.checkedMultiply方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。