Class IntStack


  • public final class IntStack
    extends java.lang.Object
    Special class for unboxed int stack
    Version:
    4.8
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()  
      private void ensureCapacity​(int n)
      ensure the stack can contains at least n elements
      boolean isEmpty()  
      int peek()
      returns, without removing, the top element
      int pop()
      returns the top of the stack and removes it from the stack
      void push​(int n)
      pushes the int on the stack
      int size()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • array

        public int[] array
      • currentIndex

        public int currentIndex
    • Constructor Detail

    • Method Detail

      • clear

        public void clear()
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if the stack is empty
      • size

        public int size()
        Returns:
        the number of elements of the stack
      • push

        public void push​(int n)
        pushes the int on the stack
        Parameters:
        n - the element to push
      • pop

        public int pop()
        returns the top of the stack and removes it from the stack
        Returns:
        the top element
      • peek

        public int peek()
        returns, without removing, the top element
        Returns:
        the top element
      • ensureCapacity

        private void ensureCapacity​(int n)
        ensure the stack can contains at least n elements
        Parameters:
        n - the number of elements
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object