本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}