本文整理匯總了Java中java.lang.Math.min方法的典型用法代碼示例。如果您正苦於以下問題:Java Math.min方法的具體用法?Java Math.min怎麽用?Java Math.min使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.Math
的用法示例。
在下文中一共展示了Math.min方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dumpInto
import java.lang.Math; //導入方法依賴的package包/類
/**
* Empty partially or totally the actual amount, depends on the other jug,
* filling that quantity in the other jug
* @param jug Other jug where to dump into.
*/
public void dumpInto(Jug jug) {
/**
* The quantity to fill. It will be the rest of the other jug or the
* actual amount, if it is smaller.
*/
Integer added = Math.min(jug.rest(), getAmount());
// set the amount of the other jug to indicate the filling
jug.setAmount(jug.getAmount() + added);
// set the actual amount of this jug to indicate the dump
setAmount(amount - added);
}
示例2: minMemberOccurs
import java.lang.Math; //導入方法依賴的package包/類
/**
* Returns the smallest of the minOccurs attributes of the choice members.
*/
int minMemberOccurs () {
int minOccurs = Integer.MAX_VALUE;
for (Iterator i=compositor.getMembers().iterator();i.hasNext();) {
CompositorMember member = (CompositorMember)i.next();
minOccurs = Math.min(minOccurs, member.minOccurs);
}
return minOccurs;
}
示例3: read
import java.lang.Math; //導入方法依賴的package包/類
public int read( byte b[], int off, int len ) throws IOException
{
dataAvailable=0;
int i=0, Minimum=0;
int intArray[] =
{
b.length,
InputBuffer,
len
};
/*
find the lowest nonzero value
timeout and threshold are handled on the native side
see NativeEnableReceiveTimeoutThreshold in
RS485Imp.c
*/
while(intArray[i]==0 && i < intArray.length) i++;
Minimum=intArray[i];
while( i < intArray.length )
{
if(intArray[i] > 0 )
{
Minimum=Math.min(Minimum,intArray[i]);
}
i++;
}
Minimum=Math.min(Minimum,threshold);
if(Minimum == 0) Minimum=1;
int Available=available();
int Ret = readArray( b, off, Minimum);
return Ret;
}
示例4: read
import java.lang.Math; //導入方法依賴的package包/類
public int read( byte b[], int off, int len ) throws IOException
{
dataAvailable=0;
int i=0, Minimum=0;
int intArray[] =
{
b.length,
InputBuffer,
len
};
/*
find the lowest nonzero value
timeout and threshold are handled on the native side
see NativeEnableReceiveTimeoutThreshold in
RawImp.c
*/
while(intArray[i]==0 && i < intArray.length) i++;
Minimum=intArray[i];
while( i < intArray.length )
{
if(intArray[i] > 0 )
{
Minimum=Math.min(Minimum,intArray[i]);
}
i++;
}
Minimum=Math.min(Minimum,threshold);
if(Minimum == 0) Minimum=1;
int Available=available();
int Ret = readArray( b, off, Minimum);
return Ret;
}
示例5: read
import java.lang.Math; //導入方法依賴的package包/類
public int read( byte b[], int off, int len ) throws IOException
{
dataAvailable=0;
int i=0, Minimum=0;
int intArray[] =
{
b.length,
InputBuffer,
len
};
/*
find the lowest nonzero value
timeout and threshold are handled on the native side
see NativeEnableReceiveTimeoutThreshold in
I2CImp.c
*/
while(intArray[i]==0 && i < intArray.length) i++;
Minimum=intArray[i];
while( i < intArray.length )
{
if(intArray[i] > 0 )
{
Minimum=Math.min(Minimum,intArray[i]);
}
i++;
}
Minimum=Math.min(Minimum,threshold);
if(Minimum == 0) Minimum=1;
int Available=available();
int Ret = readArray( b, off, Minimum);
return Ret;
}
示例6: add
import java.lang.Math; //導入方法依賴的package包/類
public void add(double x) {
sum_x += x;
sum_xx += x*x;
num_x += 1.0;
min_x = Math.min(min_x,x);
max_x = Math.max(max_x,x);
}
示例7: SnmpStringFixed
import java.lang.Math; //導入方法依賴的package包/類
/**
* Constructs a new <CODE>SnmpStringFixed</CODE> from the specified <CODE>bytes</CODE> array
* with the specified length.
* @param l The length of the fixed-string.
* @param v The <CODE>bytes</CODE> composing the fixed-string value.
* @exception IllegalArgumentException Either the length or the <CODE>byte</CODE> array is not valid.
*/
public SnmpStringFixed(int l, byte[] v) throws IllegalArgumentException {
if ((l <= 0) || (v == null)) {
throw new IllegalArgumentException() ;
}
int length = Math.min(l, v.length);
value = new byte[l] ;
for (int i = 0 ; i < length ; i++) {
value[i] = v[i] ;
}
for (int i = length ; i < l ; i++) {
value[i] = 0 ;
}
}
示例8: setAddress
import java.lang.Math; //導入方法依賴的package包/類
/**
* Set address
* @param address - String array of size address_size.
*/
public void setAddress(String[] address) {
int inlength = Math.min(address_size, address.length);
for (int i = 0; i < inlength; i++) {
this.address[i] = new String(address[i]);
}
}
示例9: readBoard
import java.lang.Math; //導入方法依賴的package包/類
public void readBoard(String in,boolean update){
moveSequence = "";
redTurn = true;
blueTurn = false;
try{
String[] parts;
boolean newMode = false;
char[] id = in.toCharArray();
if(id[0]=='B'){
int indexOfFirstComma = in.indexOf(",");
int indexOfFirstSlash = in.indexOf("/");
birth.clear();
survive.clear();
for(int i=1;i<indexOfFirstSlash;i++){
birth.add(Character.getNumericValue(id[i]));
}
for(int i=indexOfFirstSlash+2;i<indexOfFirstComma;i++){
survive.add(Character.getNumericValue(id[i]));
}
parts = in.substring(indexOfFirstComma+1).split(",");
}else{
parts = in.split(",");
}
if (parts.length < 5) {
throw new IOException();
}
WIDTH = HEIGHT = Math.min(Math.max(Integer.parseInt(parts[0]),3),20);
timeLimit[0]=0;
timeLimit[1] = Integer.parseInt(parts[1]);
timeLimit[2]=0;
timeLimit[3]=0;
timeBonus = Integer.parseInt(parts[2]);
int humanNum = Integer.parseInt(parts[3]);
stringToBoard(parts[4],update);
/*redDepth = (int)(((humanNum/4)-1)*2);
blueDepth = (((humanNum%4)-1)*2);
if(redDepth<0){
redBot = false;
}else{
redBot = true;
}
if(blueDepth<0){
blueBot = false;
}else{
redBot = true;
}*/
int noSwapsUntil = -1;
String[] moves = new String[parts.length-5];
for(int i = 0; i<moves.length; i++){
moves[i]=parts[i+5];
}
int moveLimit = Integer.MAX_VALUE;
if(screen==4){
moveArray = moves;
totalMoves = moveArray.length;
moveNumber = 0;
saveTiles();
}else{
saveTiles();
for (int t = 0; t < moves.length; t++) { // Go through all the moves.
makeMove(moves[t]);
}
}
updateNumbers();
updateLists();
boardStart = getBoard();
}catch (Exception e) {
JFrame frame = new JFrame("Error");
JOptionPane.showMessageDialog(frame, "Illegal game string", "Error", 0);
}
}
示例10: setQuiescentAlpha
import java.lang.Math; //導入方法依賴的package包/類
public void setQuiescentAlpha(float alpha, boolean animate) {
mAnimateToQuiescent.cancel();
alpha = Math.min(Math.max(alpha, 0), 1);
if (alpha == mQuiescentAlpha && alpha == mDrawingAlpha) return;
mQuiescentAlpha = alpha;
if (DEBUG) Log.d(TAG, "New quiescent alpha = " + mQuiescentAlpha);
if (animate) {
mAnimateToQuiescent = animateToQuiescent();
mAnimateToQuiescent.start();
} else {
setDrawingAlpha(mQuiescentAlpha);
}
}
示例11: moveUp
import java.lang.Math; //導入方法依賴的package包/類
private void moveUp() {
top = Math.max(top - pageSize, 1);
bottom = Math.min(top + pageSize - 1, selection.size());
}
示例12: moveDown
import java.lang.Math; //導入方法依賴的package包/類
private void moveDown() {
if (selection.size() == 0) return;
bottom = Math.min(bottom + pageSize, selection.size());
top = bottom - pageSize + 1;
}
示例13: getRadius
import java.lang.Math; //導入方法依賴的package包/類
/**
* Computes the half-width of the PSF for determining which pixels contribute to the emitter signal.
*
* This number is based on the greatest horizontal or vertical extent of the
* grid that the PSF is computed on. If maxRadius is smaller than that
* determined by the PSF's computational grid, then maxRadius is returned.
*
* @return The width of the PSF.
*/
@Override
public double getRadius() {
double minPixel = (double) Math.min(this.sizeX, this.sizeY) / 2;
double minSize = this.resPSF / this.resLateral * minPixel - 1;
return Math.min(minSize, this.maxRadius);
}