public interface StackModel extends ListModel
ListModel
as a stack is essentially a list with special
semantics.StackView
Modifier and Type | Method and Description |
---|---|
void |
addStackDataListener(ListDataListener listener)
Add a
ListDataListener to this model's list of listeners. |
void |
append(Object obj)
Append an object to the bottom of the stack.
|
void |
drop()
Drop an item off the stack.
|
int |
getDepth()
Get the depth of the stack.
|
boolean |
isEmpty()
Determine if the stack is empty.
|
Object |
peek()
Retrieve the topmost item from the stack (without removing the item from
the stack).
|
Object |
pick(int index)
Remove an object from the stack.
|
Object |
pop()
Pop an object off the stack.
|
void |
push(Object obj)
Push an object on the stack.
|
void |
removeStackDataListener(ListDataListener listener)
Remove a
ListDataListener from this model's list of
listeners. |
void |
swap()
Swap the topmost items on the stack.
|
addListDataListener, getElementAt, getSize, removeListDataListener
void push(Object obj)
obj
- The object to push.Object pop() throws EmptyStackException
EmptyStackException
void drop()
EmptyStackException
- If the stack is empty.Object peek() throws ArrayIndexOutOfBoundsException
EmptyStackException
- If the stack is empty.ArrayIndexOutOfBoundsException
int getDepth()
void swap() throws EmptyStackException
EmptyStackException
- If the stack is empty.boolean isEmpty()
true
if there are no items in the stack, and
false
otherwise.Object pick(int index) throws ArrayIndexOutOfBoundsException, EmptyStackException
index
- The offset (from the top of the stack) of the item to remove.EmptyStackException
- If the stack is empty.ArrayIndexOutOfBoundsException
- If the value of
index
is out of range.void append(Object obj)
obj
- The object to append.void addStackDataListener(ListDataListener listener)
ListDataListener
to this model's list of listeners.
Since a stack is essentially a list with some special semantics,
ListDataListeners
are used.listener
- The listener to add.void removeStackDataListener(ListDataListener listener)
ListDataListener
from this model's list of
listeners. Since a stack is essentially a list with some special
semantics, ListDataListeners
are used.listener
- The listener to add.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses