public class ByteStack extends Object
Constructor and Description |
---|
ByteStack()
Creates an empty primitive stack.
|
ByteStack(byte[] numbas)
Creates a stack prepopulating it with values.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Empties the contents of the stack.
|
boolean |
empty()
Tests if this stack is empty.
|
byte |
get(int index)
Gets items from the stack where the index is zero based and the top of
the stack is at an index of size()-1 with the bottom of the stack at an
index of 0.
|
byte |
peek()
Looks at the top of this stack without removing it.
|
byte |
peek(int n)
Return the n'th byte down the stack, where 0 is the top element and
[size()-1] is the bottom element.
|
byte |
pop()
Removes the value at the top of this stack and returns it.
|
byte |
push(byte item)
Pushes a value onto the top of this stack.
|
int |
search(byte item)
Returns the 1-based position where a value is on this stack.
|
int |
size()
Gets the size of this stack.
|
public ByteStack()
public ByteStack(byte[] numbas)
numbas
- the array to addpublic boolean empty()
public byte peek()
EmptyStackException
- if this stack is emptypublic byte peek(int n)
n
- the element indexEmptyStackException
- if the stack is emptyIndexOutOfBoundsException
- if the index is out of boundspublic byte pop()
EmptyStackException
- if this stack is emptypublic byte push(byte item)
item
- the value to push onto this stackpublic int search(byte item)
item
- the value to search for from the top downpublic byte get(int index)
index
- the index into the stack treated as a listpublic int size()
public void clear()
Copyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.