Java 8 EmptyStackException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 EmptyStackException class.

This code example shows how to use the following methods:
    } 
 
    public E pop() { 
        Deque<E> st = deque.get();
        if (st == null) {
            throw new EmptyStackException();
        } 
        E val = st.pop();
        if (st.isEmpty()) {
            deque.remove();
        } 
        return val;
    } 
 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     * Analogous to {@link java.util.Stack#peek}. 
     */ 
    public E peek() { 
        int len = size();
        if (len <= 0) {
            throw new EmptyStackException();
        } 
        return get(len - 1);
    } 
} 
 
// End ArrayStack.java 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
    private void checkEmptyStack() 
    { 
        if (this.delegate.isEmpty())
        { 
            throw new EmptyStackException();
        } 
    } 
 
    public BooleanList pop(int count)
    { 
        this.checkPositiveValueForCount(count);
        this.checkSizeLessThanCount(count);
        if (count == 0)
        { 
            return new BooleanArrayList(0); 
        } 
        MutableBooleanList subList = new BooleanArrayList(count);
        while (count > 0)
        { 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
  /** 
   * @return the int at the top of the stack 
   */ 
  public int peek() throws EmptyStackException { 
    if (isEmpty()) { 
      throw new EmptyStackException();
    } 
    return state[top];
  } 
 
  /** 
   * pop the stack 
   * @return the int at the top of the stack 
   */ 
  public int pop() throws EmptyStackException{ 
    if (isEmpty()) { 
      throw new EmptyStackException();
    } 
    return state[top--];
  } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	 * @return the last element. 
	 */ 
	public E pop() 
	{ 
		if( mSize == 0 )
			throw new EmptyStackException();
		return mElements.set(--mSize, null);
	} 
 
	/** 
	 * peek. 
	 *  
	 * @return the last element. 
	 */ 
	public E peek() 
	{ 
		if( mSize == 0 )
			throw new EmptyStackException();
		return mElements.get(mSize-1);
	} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
   static class ErrorInducingInterceptor extends CommandInterceptor { 
      @Override 
      public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
         Object k = command.getKey();
         if (k == FailureType.EXCEPTION_FROM_INTERCEPTOR)
            throw new EmptyStackException();
         else if (k == FailureType.ERROR_FROM_INTERCEPTOR)
            throw new ClassCircularityError();
         else 
            return super.visitPutKeyValueCommand(ctx, command);
      } 
   } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    } 
 
    public T pop() { 
        Stack<T> stack = threadLocalStack.get();
        if (stack == null) {
            throw new EmptyStackException();
        } 
        try { 
            return stack.pop();
        } finally { 
            if (stack.isEmpty()) {
                threadLocalStack.remove();
            } 
        } 
    } 
 
    /** 
     * The injection point being operated on for this thread 
     * 
     * @return the current injection point 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     * @throws EmptyStackException  if the stack is empty 
     */ 
    public Object peek() throws EmptyStackException {
        int n = size();
        if (n <= 0) {
            throw new EmptyStackException();
        } else { 
            return get(n - 1);
        } 
    } 
 
    /** 
     * Returns the n'th item down (zero-relative) from the top of this 
     * stack without removing it. 
     * 
     * @param n  the number of items down to go 
     * @return the n'th item on the stack, zero relative 
     * @throws EmptyStackException  if there are not enough items on the 
     *  stack to satisfy this request 
     */ 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	public final T peek() 
	{ 
		int size = size();
		if (size == 0)
		{ 
			throw new EmptyStackException();
		} 
		return get(size - 1);
	} 
 
	/** 
	 * Tests if this stack is empty. 
	 *  
	 * @return <code>true</code> if and only if this stack contains no items; <code>false</code> 
	 *         otherwise. 
	 */ 
	public final boolean empty() 
	{ 
		return size() == 0;
	} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
	public final T peek() 
	{ 
		int size = size();
		if (size == 0)
		{ 
			throw new EmptyStackException();
		} 
		return get(size - 1);
	} 
 
	/** 
	 * Removes the object at the top of this stack and returns that object. 
	 *  
	 * @return The object at the top of this stack 
	 * @exception EmptyStackException 
	 *                If this stack is empty. 
	 */ 
	public final T pop() 
	{ 
		final T top = peek();
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 EmptyStackException Methods: