本文整理汇总了Java中com.google.common.primitives.Ints.max方法的典型用法代码示例。如果您正苦于以下问题:Java Ints.max方法的具体用法?Java Ints.max怎么用?Java Ints.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.primitives.Ints
的用法示例。
在下文中一共展示了Ints.max方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BucketAllocator
import com.google.common.primitives.Ints; //导入方法依赖的package包/类
BucketAllocator(long availableSpace, int[] bucketSizes)
throws BucketAllocatorException {
this.bucketSizes = bucketSizes == null ? DEFAULT_BUCKET_SIZES : bucketSizes;
Arrays.sort(this.bucketSizes);
this.bigItemSize = Ints.max(this.bucketSizes);
this.bucketCapacity = FEWEST_ITEMS_IN_BUCKET * bigItemSize;
buckets = new Bucket[(int) (availableSpace / bucketCapacity)];
if (buckets.length < this.bucketSizes.length)
throw new BucketAllocatorException(
"Bucket allocator size too small - must have room for at least "
+ this.bucketSizes.length + " buckets");
bucketSizeInfos = new BucketSizeInfo[this.bucketSizes.length];
for (int i = 0; i < this.bucketSizes.length; ++i) {
bucketSizeInfos[i] = new BucketSizeInfo(i);
}
for (int i = 0; i < buckets.length; ++i) {
buckets[i] = new Bucket(bucketCapacity * i);
bucketSizeInfos[i < this.bucketSizes.length ? i : this.bucketSizes.length - 1]
.instantiateBucket(buckets[i]);
}
this.totalSize = ((long) buckets.length) * bucketCapacity;
}
示例2: raycast
import com.google.common.primitives.Ints; //导入方法依赖的package包/类
/**
* Casts a ray from origin to target, destroying blocks along the way and diminishing power.
*
* <li>Does not alter origin or target vector.
* <li>Destroys blocks
* <li>Returns unused power to store back in the cylinder map
*/
public float raycast(World world, MutableVector origin, MutableVector target, float power) {
IBlockState air = Blocks.AIR.getDefaultState();
float x = origin.x + 0.5f;
float y = origin.y + 0.5f;
float z = origin.z + 0.5f;
float dx = target.x - origin.x;
float dy = target.y - origin.y;
float dz = target.z - origin.z;
int d = Ints.max((int)Math.abs(dx), (int)Math.abs(dy), (int)Math.abs(dz));
dx /= (float)d;
dy /= (float)d;
dz /= (float)d;
float curPower = power;
for(int i=0; i<=d; i++) {
BlockPos here = new BlockPos((int)x, (int)y, (int)z);
IBlockState state = world.getBlockState(here);
if (state!=air) {
//curPower =
float remaining = explodeBlock(world, here, curPower);
if (remaining<=0) return 0;
//if (curPower<=0) return 0;
curPower = remaining;
}
x += dx;
y += dy;
z += dz;
}
return curPower;
}