本文整理匯總了Java中com.google.common.primitives.Ints.min方法的典型用法代碼示例。如果您正苦於以下問題:Java Ints.min方法的具體用法?Java Ints.min怎麽用?Java Ints.min使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.primitives.Ints
的用法示例。
在下文中一共展示了Ints.min方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateRaindrops
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
private int calculateRaindrops(MatchPlayerState player, int count, boolean scaled, double percent) {
if(scaled) {
final Match match = player.getMatch();
count += (int) ((double) match.getParticipatingPlayers().size() / match.getMaxPlayers() * RaindropConstants.MATCH_FULLNESS_BONUS);
if(player.getParty() instanceof Team) {
count += Ints.min((int) (Math.sqrt(((Team) player.getParty()).getCumulativeParticipation(player.getPlayerId()).getSeconds()) / RaindropConstants.PLAY_TIME_BONUS), RaindropConstants.PLAY_TIME_BONUS_CUTOFF);
}
}
return RaindropUtil.calculateRaindrops(player.getPlayerId(), (int) (count * percent), true);
}
示例2: receiveHeat
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
@Override
public int receiveHeat(int amount, boolean simulate) {
int toReceive = Ints.min(amount, max-cur, maxReceive);
if (toReceive<minReceive) toReceive = 0;
if (!simulate) {
cur += toReceive;
markDirty();
}
return toReceive;
}
示例3: extractHeat
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
@Override
public int extractHeat(int amount, boolean simulate) {
int toExtract = Ints.min(amount, cur, maxExtract);
if (!simulate) {
cur -= toExtract;
markDirty();
}
return toExtract;
}
示例4: update
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
@Override
public void update() {
if (progress>=H_PER_SMELT) {
//We're finished. Don't do *anything* until we can kick the item into the output slot.
//Note: By now the "work-slot" has always already been replaced by a smelting result.
if (itemStorage.getStackInSlot(StandardMachineSlots.WORK).isEmpty()) {
//Invalid state! Kick us back into a valid state.
progress = 0;
this.markDirty();
return;
}
//System.out.println("Smelt end step. workslot:"+itemStorage.getStackInSlot(SLOT_WORK)+" outputslot:"+itemStorage.getStackInSlot(MachineItemStorageView.SLOT_MACHINE_OUTPUT));
ItemStack result = itemStorage.insertItem(StandardMachineSlots.OUTPUT, itemStorage.getStackInSlot(StandardMachineSlots.WORK), false);
itemStorage.setStackInSlot(StandardMachineSlots.WORK, result);
//System.out.println("End End step. workslot:"+itemStorage.getStackInSlot(SLOT_WORK)+" outputslot:"+itemStorage.getStackInSlot(MachineItemStorageView.SLOT_MACHINE_OUTPUT));
if (result==null || result.isEmpty()) {
//Good! Kill our progress. We can resume work next tick
progress = 0;
this.markDirty();
this.markActive(false);
} else {
//We're still stalled :(
//System.out.println("Continue stall.");
}
return;
}
int heatNeeded = H_PER_SMELT - progress;
int heatAvailable = heatStorage.getHeatStored();
int heatToConsume = Ints.min(heatAvailable, HEAT_EFFICIENCY, heatNeeded);
if (itemStorage.getStackInSlot(StandardMachineSlots.INPUT).isEmpty()) {
if (progress>0) {
progress = 0;
markDirty();
}
return;
}
if (heatToConsume<=0) {
//Backpedal progress
if (progress>0) {
progress--;
markDirty();
}
} else {
//Apply progress
progress += heatStorage.extractHeat(heatToConsume, false);
markActive(true);
if (progress>=H_PER_SMELT) {
doSmelt();
}
}
}
示例5: writeBytesTo
import com.google.common.primitives.Ints; //導入方法依賴的package包/類
/**
* Copies bytes from this hash code into {@code dest}.
*
* @param dest the byte array into which the hash code will be written
* @param offset the start offset in the data
* @param maxLength the maximum number of bytes to write
* @return the number of bytes written to {@code dest}
* @throws IndexOutOfBoundsException if there is not enough room in {@code dest}
*/
@CanIgnoreReturnValue
public int writeBytesTo(byte[] dest, int offset, int maxLength) {
maxLength = Ints.min(maxLength, bits() / 8);
Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length);
writeBytesToImpl(dest, offset, maxLength);
return maxLength;
}