Top Description Fields Constructors Methods
org.h2.util

public final Class ByteStack

extends Object
Class Inheritance
Imports
java.util.Arrays, .NoSuchElementException

The stack of byte values. This class is not synchronized and should not be used by multiple threads concurrently.

Field Summary

Modifier and TypeField and Description
private byte[]
private static final int
private int

Constructor Summary

AccessConstructor and Description
public
ByteStack()

Creates a new empty instance.

Method Summary

Modifier and TypeMethod and Description
private void
grow(int length)

public boolean

Returns:

true if this stack is empty
isEmpty
()

Returns true if this stack is empty.

public int

Returns:

the item at the top of this stack, or default value
peek
(int
value to return if stack is empty
defaultValue
)

Looks at the item at the top of this stack without removing it.

public int

Returns:

the item at the top of this stack, or default value
poll
(int
value to return if stack is empty
defaultValue
)

Removes the item at the top of this stack and returns that item.

public byte

Returns:

the item at the top of this stack
pop
()

Removes the item at the top of this stack and returns that item.

public void
push(byte
the item to push
item
)

Pushes an item onto the top of this stack.

public int

Returns:

the number of items in this stack
size
()

Returns the number of items in this stack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arrayback to summary
private byte[] array
MAX_ARRAY_SIZEback to summary
private static final int MAX_ARRAY_SIZE
sizeback to summary
private int size

Constructor Detail

ByteStackback to summary
public ByteStack()

Creates a new empty instance.

Method Detail

growback to summary
private void grow(int length)
isEmptyback to summary
public boolean isEmpty()

Returns true if this stack is empty.

Returns:boolean

true if this stack is empty

peekback to summary
public int peek(int defaultValue)

Looks at the item at the top of this stack without removing it.

Parameters
defaultValue:int

value to return if stack is empty

Returns:int

the item at the top of this stack, or default value

pollback to summary
public int poll(int defaultValue)

Removes the item at the top of this stack and returns that item.

Parameters
defaultValue:int

value to return if stack is empty

Returns:int

the item at the top of this stack, or default value

popback to summary
public byte pop()

Removes the item at the top of this stack and returns that item.

Returns:byte

the item at the top of this stack

Exceptions
NoSuchElementException:
if stack is empty
pushback to summary
public void push(byte item)

Pushes an item onto the top of this stack.

Parameters
item:byte

the item to push

sizeback to summary
public int size()

Returns the number of items in this stack.

Returns:int

the number of items in this stack