當前位置: 首頁>>代碼示例>>Java>>正文


Java Math.min方法代碼示例

本文整理匯總了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);
}
 
開發者ID:VigoTech,項目名稱:reto,代碼行數:19,代碼來源:Jug.java

示例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;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:12,代碼來源:ChoiceGuard.java

示例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;
}
 
開發者ID:brok1n,項目名稱:SerialAssistant,代碼行數:33,代碼來源:RS485.java

示例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;
}
 
開發者ID:brok1n,項目名稱:SerialAssistant,代碼行數:33,代碼來源:Raw.java

示例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;
}
 
開發者ID:brok1n,項目名稱:SerialAssistant,代碼行數:33,代碼來源:I2C.java

示例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);
}
 
開發者ID:BigBayes,項目名稱:BNPMix.java,代碼行數:8,代碼來源:Summary.java

示例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 ;
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:SnmpStringFixed.java

示例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]);
    }
}
 
開發者ID:owainkenwayucl,項目名稱:uclapi-java,代碼行數:11,代碼來源:Room.java

示例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);
    }       
}
 
開發者ID:hanss314,項目名稱:GOLAD,代碼行數:73,代碼來源:MyWorld.java

示例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);
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:14,代碼來源:KeyButtonView.java

示例11: moveUp

import java.lang.Math; //導入方法依賴的package包/類
private void moveUp() {
  top = Math.max(top - pageSize, 1);
  bottom = Math.min(top + pageSize - 1, selection.size());
}
 
開發者ID:google,項目名稱:codeu_project_2017,代碼行數:5,代碼來源:ListNavigator.java

示例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;
}
 
開發者ID:google,項目名稱:codeu_project_2017,代碼行數:6,代碼來源:ListNavigator.java

示例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);
}
 
開發者ID:LEB-EPFL,項目名稱:SASS,代碼行數:16,代碼來源:GibsonLanniPSF.java


注:本文中的java.lang.Math.min方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。