Interface Stack<N>

All Known Subinterfaces:
BlockingStack<N>
All Known Implementing Classes:
ConcurrentStack, FixedStack

public interface Stack<N>
Created by jcairns on 6/11/14.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear the stack
    boolean
    Linear search the stack for contains - not an efficient operation
    boolean
     
    show the current stack top
    pop()
    pop and return the element from the top of the stack
    boolean
    push(N n)
    Add the element to the stack top, optionally failing if there is no capacity (overflow)
    int
     
    int
     
  • Method Details

    • contains

      boolean contains(N n)
      Linear search the stack for contains - not an efficient operation
      Parameters:
      n - - Object to test for containment
      Returns:
      boolean - true if n is contained somewhere in the stack
    • push

      boolean push(N n)
      Add the element to the stack top, optionally failing if there is no capacity (overflow)
      Parameters:
      n - - element to push
      Returns:
      boolean - true if push succeeded
    • peek

      N peek()
      show the current stack top
      Returns:
      N - the element at the top of the stack or null
    • pop

      N pop()
      pop and return the element from the top of the stack
      Returns:
      N - the element, or null if the stack is empty
    • size

      int size()
      Returns:
      int - the size of the stack in number of elements
    • remainingCapacity

      int remainingCapacity()
      Returns:
      int - the number of empty slots available in the stack
    • isEmpty

      boolean isEmpty()
      Returns:
      boolean - true if stack is empty
    • clear

      void clear()
      clear the stack