本文整理匯總了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;
}