Advertisement
LoganBlackisle

Stack interface

Jun 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. package prep_27_stack;
  2.  
  3. /**
  4. * An implementation of a stack as a sequence of nodes.
  5. */
  6. public interface StackI {
  7.  
  8. /**
  9. * Adds an element to the top of the stack.
  10. *
  11. * @param element
  12. * the element to add
  13. */
  14. public void push(Object element);
  15.  
  16. /**
  17. * Removes the element from the top of the stack.
  18. *
  19. * @return the removed element
  20. */
  21. public Object pop();
  22.  
  23. /**
  24. * Returns the element from the top of the stack. The stack is unchanged
  25. *
  26. * @return the element from the top of the stack
  27. */
  28. public Object peek();
  29.  
  30. /**
  31. * Checks whether this stack is empty.
  32. *
  33. * @return true if the stack is empty
  34. */
  35. public boolean isEmpty();
  36.  
  37. /**
  38. * The number of elements on the stack.
  39. *
  40. * @return the number of elements on the stack
  41. */
  42. public int size();
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement