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


Java EmptyStackException類代碼示例

本文整理匯總了Java中java.util.EmptyStackException的典型用法代碼示例。如果您正苦於以下問題:Java EmptyStackException類的具體用法?Java EmptyStackException怎麽用?Java EmptyStackException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EmptyStackException類屬於java.util包,在下文中一共展示了EmptyStackException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: cleanUp

import java.util.EmptyStackException; //導入依賴的package包/類
@AfterClass
public static void cleanUp()
{
    resetPasswordService.setSendEmailAsynchronously(Boolean.valueOf(
                globalProperties.getProperty("system.reset-password.sendEmailAsynchronously")));
    resetPasswordService.setDefaultEmailSender((String) globalProperties.get("system.email.sender.default"));

    AuthenticationUtil.setRunAsUserSystem();
    transactionHelper.doInTransaction(() ->
    {
        personService.deletePerson(testPerson.userName);
        return null;
    });

    // Restore authentication to pre-test state.
    try
    {
        AuthenticationUtil.popAuthentication();
    }
    catch(EmptyStackException e)
    {
        // Nothing to do.
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:25,代碼來源:ResetPasswordServiceImplTest.java

示例2: popIfFrist

import java.util.EmptyStackException; //導入依賴的package包/類
public synchronized boolean popIfFrist(T t) {

        if (tStack.peek().equals(t)) {
            T temp = tStack.pop();
            try {
                rStack.pop();

                return true;
            } catch (EmptyStackException e) {
                tStack.push(temp);
                return false;
            }
        }

        return false;
    }
 
開發者ID:XaskYSab,項目名稱:xmlpullparserutil,代碼行數:17,代碼來源:PairStack.java

示例3: startCapture

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * Start capturing thread's output.
 */
public static void startCapture() {
    CaptureLog log = null;
    if (!reuse.isEmpty()) {
        try {
            log = reuse.pop();
        } catch (EmptyStackException e) {
            log = new CaptureLog();
        }
    } else {
        log = new CaptureLog();
    }
    Stack<CaptureLog> stack = logs.get();
    if (stack == null) {
        stack = new Stack<CaptureLog>();
        logs.set(stack);
    }
    stack.push(log);
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:22,代碼來源:SystemLogHandler.java

示例4: endPrefixMapping

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * Process notification that a namespace prefix is going out of scope.
 *
 * @param prefix Prefix that is going out of scope
 *
 * @exception SAXException if a parsing error is to be reported
 */
@Override
public void endPrefixMapping(String prefix) throws SAXException {

    if (saxLog.isDebugEnabled()) {
        saxLog.debug("endPrefixMapping(" + prefix + ")");
    }

    // Deregister this prefix mapping
    ArrayStack<String> stack = namespaces.get(prefix);
    if (stack == null) {
        return;
    }
    try {
        stack.pop();
        if (stack.empty())
            namespaces.remove(prefix);
    } catch (EmptyStackException e) {
        throw createSAXException("endPrefixMapping popped too many times");
    }

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:29,代碼來源:Digester.java

示例5: pop

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * <p>Pops (gets and removes) the top object from the stack with the given name.</p>
 *
 * <p><strong>Note:</strong> a stack is considered empty
 * if no objects have been pushed onto it yet.</p>
 * 
 * @param stackName the name of the stack from which the top value is to be popped
 * @return the top <code>Object</code> on the stack or or null if the stack is either 
 * empty or has not been created yet
 * @throws EmptyStackException if the named stack is empty
 *
 * @since 1.6
 */
public Object pop(String stackName) {
    Object result = null;
    ArrayStack<Object> namedStack = stacksByName.get(stackName);
    if (namedStack == null) {
        if (log.isDebugEnabled()) {
            log.debug("Stack '" + stackName + "' is empty");
        }
        throw new EmptyStackException();
        
    } else {
    
        result = namedStack.pop();
    }
    return result;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:29,代碼來源:Digester.java

示例6: pop

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * Hide the currently displayed HUD, and show the one below it on the stack
 */
public synchronized void pop() {
    Debug.d("Popping one off the HUD stack");
    try {
        PhoeniciaHUD previousHUD = this.hudStack.pop();
        if (previousHUD != null) {
            this.currentHUD.hide();
            this.currentHUD.close();
            this.setHudLayer(previousHUD);
            this.currentHUD = previousHUD;
            previousHUD.show();
        }
    } catch (EmptyStackException e) {
        Debug.d("Nothing to pop off the stack");
        return;
    }
}
 
開發者ID:Linguaculturalists,項目名稱:Phoenicia,代碼行數:20,代碼來源:HUDManager.java

示例7: peek

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * <p>Gets the top object from the stack with the given name.
 * This method does not remove the object from the stack.
 * </p>
 * <p><strong>Note:</strong> a stack is considered empty
 * if no objects have been pushed onto it yet.</p>
 *
 * @param stackName the name of the stack to be peeked
 * @return the top <code>Object</code> on the stack or null if the stack is either 
 * empty or has not been created yet
 * @throws EmptyStackException if the named stack is empty 
 *
 * @since 1.6
 */
public Object peek(String stackName) {
    Object result = null;
    ArrayStack namedStack = (ArrayStack) stacksByName.get(stackName);
    if (namedStack == null ) {
        if (log.isDebugEnabled()) {
            log.debug("Stack '" + stackName + "' is empty");
        }        
        throw new EmptyStackException();
    
    } else {
    
        result = namedStack.peek();
    }
    return result;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:Digester.java

示例8: popAt

import java.util.EmptyStackException; //導入依賴的package包/類
@Override
public T popAt(final int stackNumber) {
    if (stacks.isEmpty()) {
        throw new EmptyStackException();
    }

    if (stacks.size() <= stackNumber - 1) {
        throw new IllegalArgumentException(
                "Stack #" + stackNumber + " does not exists"
        );
    }

    T item = stacks.get(stackNumber).pop();

    if (stacks.get(stackNumber).isEmpty()) {
        stacks.remove(stackNumber);
    }

    return item;
}
 
開發者ID:rostykerei,項目名稱:cci,代碼行數:21,代碼來源:SetOfStacksFull.java

示例9: poa

import java.util.EmptyStackException; //導入依賴的package包/類
public POA poa(Servant self)
{
    try {
        return (POA)orb.peekInvocationInfo().oa();
    } catch (EmptyStackException exception){
        POA returnValue = factory.lookupPOA(self);
        if (returnValue != null) {
            return returnValue;
        }

        throw wrapper.noContext( exception ) ;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:DelegateImpl.java

示例10: peek

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * Returns the top item off of this stack without removing it.
 *
 * @return the top item on the stack
 * @throws EmptyStackException  if the stack is empty
 */
public E peek() throws EmptyStackException {
    int n = size();
    if (n <= 0) {
        throw new EmptyStackException();
    } else {
        return get(n - 1);
    }
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:15,代碼來源:ArrayStack.java

示例11: pop

import java.util.EmptyStackException; //導入依賴的package包/類
public T pop()
{
  if( isEmpty() )
  {
    throw new EmptyStackException();
  }
  return _list.remove( size() - 1 );
}
 
開發者ID:manifold-systems,項目名稱:manifold,代碼行數:9,代碼來源:Stack.java

示例12: peek

import java.util.EmptyStackException; //導入依賴的package包/類
public Object peek() {
int	len = size();

if (len == 0)
    throw new EmptyStackException();
return get(len - 1);
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:ArrayListStack.java

示例13: dequeue

import java.util.EmptyStackException; //導入依賴的package包/類
/**
* 從該Queue中取出元素, 並把該元素刪除
* @return 最早進Queue的元素
*/
Item dequeue() throws EmptyStackException {
    if (sizeFirstQ == 0) {
        if (sizeSecondQ > 0) {
            //如果firstQ空而secondQ非空, 就將這兩個Stack互換
            Stack<Item> tmpQ = firstQ;
            firstQ = secondQ;
            secondQ = tmpQ;
            sizeFirstQ = sizeSecondQ;
            sizeSecondQ = 0;
        } else if (sizeS > 0 && sizeS < maxCapacity) {
            //如果s中元素不足maxCapacity, 就把所以的元素移進firstQ
            while (!s.isEmpty()) {
                sizeS--;
                firstQ.push(s.pop());
                sizeFirstQ++;
            }
        } else if(sizeS >= maxCapacity) {
            //如果s中元素大於maxCapacity, 就把maxCapacity個元素移進firstQ
            for (int i = 0; i < maxCapacity; i++) {
                sizeS--;
                firstQ.push(s.pop());
                sizeFirstQ++;
            }
        } else {
            throw new EmptyStackException();
        }
        
    } 
    
    //如果firstQ有元素那就從firstQ中取元素出來
    sizeFirstQ--;
    return firstQ.pop();
}
 
開發者ID:DCMMC,項目名稱:Java-Algorithms-Learning,代碼行數:38,代碼來源:BagsQueuesStacks.java

示例14: pop

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * pop.
 * 
 * @return the last element.
 */
public E pop()
{
	if( mSize == 0 )
		throw new EmptyStackException();
	return mElements.set(--mSize, null);
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:12,代碼來源:Stack.java

示例15: setTop

import java.util.EmptyStackException; //導入依賴的package包/類
/**
 * Sets an object at a the top of the statck
 *
 *
 * @param val object to set at the top
 * @throws  EmptyStackException  if this stack is empty.
 */
public void setTop(Object val)
{
  try {
    m_map[m_firstFree - 1] = val;
  }
  catch (ArrayIndexOutOfBoundsException e)
  {
    throw new EmptyStackException();
  }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:ObjectStack.java


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