Package org.h2.util

Class ByteStack

java.lang.Object
org.h2.util.ByteStack

public final class ByteStack extends Object
The stack of byte values. This class is not synchronized and should not be used by multiple threads concurrently.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
     
    private static final int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new empty instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    grow(int length)
     
    boolean
    Returns true if this stack is empty.
    int
    peek(int defaultValue)
    Looks at the item at the top of this stack without removing it.
    int
    poll(int defaultValue)
    Removes the item at the top of this stack and returns that item.
    byte
    pop()
    Removes the item at the top of this stack and returns that item.
    void
    push(byte item)
    Pushes an item onto the top of this stack.
    int
    Returns the number of items in this stack.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_ARRAY_SIZE

      private static final int MAX_ARRAY_SIZE
      See Also:
    • size

      private int size
    • array

      private byte[] array
  • Constructor Details

    • ByteStack

      public ByteStack()
      Creates a new empty instance.
  • Method Details

    • push

      public void push(byte item)
      Pushes an item onto the top of this stack.
      Parameters:
      item - the item to push
    • pop

      public byte pop()
      Removes the item at the top of this stack and returns that item.
      Returns:
      the item at the top of this stack
      Throws:
      NoSuchElementException - if stack is empty
    • poll

      public int poll(int defaultValue)
      Removes the item at the top of this stack and returns that item.
      Parameters:
      defaultValue - value to return if stack is empty
      Returns:
      the item at the top of this stack, or default value
    • peek

      public int peek(int defaultValue)
      Looks at the item at the top of this stack without removing it.
      Parameters:
      defaultValue - value to return if stack is empty
      Returns:
      the item at the top of this stack, or default value
    • isEmpty

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

      public int size()
      Returns the number of items in this stack.
      Returns:
      the number of items in this stack
    • grow

      private void grow(int length)