当前位置: 首页>>代码示例>>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;未经允许,请勿转载。