public final class Stack
extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Stack.AccessException
Access exception.
|
static class |
Stack.CastException
Cast exception.
|
static class |
Stack.LimitsException
Limits exception.
|
Constructor and Description |
---|
Stack()
Constructs a new stack.
|
Stack(Optional<Task> task)
Constructs a new stack.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears this stack.
|
Task |
getTask()
Gets the task.
|
void |
insert(int position,
Serializable object)
Inserts an object at a position on this stack.
|
boolean |
isDropped()
Asks if this stack, as a mark, is dropped.
|
boolean |
isEmpty()
Asks if the stack is empty.
|
boolean |
isMarked()
Asks if this stack is marked.
|
Stack |
mark()
Marks the stack.
|
Serializable |
peek()
Peeks at the top of this stack.
|
Serializable |
peek(Class<?> expectedClass)
Peeks at the top of this stack.
|
Serializable |
peek(int position)
Peeks at a position on this stack.
|
double |
peekDoubleValue()
Peeks at the double at the top of this stack.
|
long |
peekLongValue()
Peeks at the long at the top of this stack.
|
String |
peekStringValue()
Peeks at the string for the value at the top of this stack.
|
Serializable |
pop()
Pops the object at the top of this stack.
|
Serializable |
pop(Class<?> expectedClass)
Pops the object at the top of this stack.
|
boolean |
popBooleanValue()
Pops the boolean at the top of this stack.
|
double |
popDoubleValue()
Pops the double at the top of this stack.
|
int |
popIntValue()
Pops the int at the top of this stack.
|
long |
popLongValue()
Pops the long at the top of this stack.
|
String |
popStringValue()
Pops the string at the top of this stack.
|
void |
push(boolean value)
Pushes a boolean on this stack.
|
void |
push(double value)
Pushes a double on this stack.
|
void |
push(long value)
Pushes a long on this stack.
|
void |
push(Optional<? extends Serializable> object)
Pushes an optional object on this stack (null when empty).
|
void |
push(Serializable object)
Pushes an object on this stack.
|
Serializable |
remove(int position)
Removes the object at a position on this stack.
|
void |
reverse()
Reverses the content order of this stack.
|
int |
size()
Returns the size of this stack.
|
Object[] |
toArray()
Returns this stack's content in an object array.
|
Object[] |
toArrayAll()
Returns all stacks content in an object array.
|
int |
totalSize()
Returns the total size of this stack and of the marks.
|
void |
unmark()
Unmarks the stack.
|
void |
unmarkAll()
Remove all marks.
|
public Stack()
public Stack(@Nonnull Optional<Task> task)
task
- The stack's owner.public void clear()
@Nonnull @CheckReturnValue public Task getTask()
public void insert(int position, @Nullable Serializable object) throws Stack.LimitsException
position
- The origin zero position.object
- The object to insert.Stack.LimitsException
- When the position is outside the stack.@CheckReturnValue public boolean isDropped()
@CheckReturnValue public boolean isEmpty()
@CheckReturnValue public boolean isMarked()
@Nonnull @CheckReturnValue public Stack mark()
@Nullable @CheckReturnValue public Serializable peek() throws Stack.LimitsException
Stack.LimitsException
- When the stack is empty.@Nonnull @CheckReturnValue public Serializable peek(@Nonnull Class<?> expectedClass) throws Stack.LimitsException, Stack.CastException
expectedClass
- The expected class.Stack.LimitsException
- When the stack is empty.Stack.CastException
- When the value has not the expected class.@Nullable @CheckReturnValue public Serializable peek(int position) throws Stack.LimitsException
position
- The origin zero position.Stack.LimitsException
- When the position is outside the stack.@CheckReturnValue public double peekDoubleValue() throws Stack.AccessException
Stack.AccessException
- When appropriate.@CheckReturnValue public long peekLongValue() throws Stack.LimitsException, Stack.CastException
Stack.LimitsException
- When the position is outside the stack.Stack.CastException
- When the value is not a number.@Nonnull @CheckReturnValue public String peekStringValue() throws Stack.LimitsException
Stack.LimitsException
- When the stack is empty.@Nullable public Serializable pop() throws Stack.LimitsException
Stack.LimitsException
- When the stack is empty.@Nullable @CheckReturnValue public Serializable pop(@Nonnull Class<?> expectedClass) throws Stack.LimitsException, Stack.CastException
expectedClass
- The expected class.Stack.LimitsException
- When the stack is empty.Stack.CastException
- When the value has not the expected class.@CheckReturnValue public boolean popBooleanValue() throws Stack.LimitsException, Stack.CastException
Stack.LimitsException
- When the stack is empty.Stack.CastException
- When the value is not a boolean.@CheckReturnValue public double popDoubleValue() throws Stack.LimitsException, Stack.CastException
Stack.LimitsException
- When the stack is empty.Stack.CastException
- When the value is not a number.@CheckReturnValue public int popIntValue() throws Stack.LimitsException, Stack.CastException
Stack.LimitsException
- When the stack is empty.Stack.CastException
- When the value is not an number.@CheckReturnValue public long popLongValue() throws Stack.LimitsException, Stack.CastException
Stack.LimitsException
- When the stack is empty.Stack.CastException
- When the value is not a number.@Nonnull @CheckReturnValue public String popStringValue() throws Stack.LimitsException
Stack.LimitsException
- When the stack is empty.public void push(boolean value)
value
- The boolean value.public void push(double value)
value
- The double value.public void push(long value)
value
- The long value.public void push(@Nonnull Optional<? extends Serializable> object)
object
- The optional object.public void push(@Nullable Serializable object)
object
- The object.@Nullable @CheckReturnValue public Serializable remove(int position) throws Stack.LimitsException
position
- The origin zero position.Stack.LimitsException
- When the position is outside the stack.public void reverse()
@CheckReturnValue public int size()
@Nonnull @CheckReturnValue public Object[] toArray()
@Nonnull @CheckReturnValue public Object[] toArrayAll()
@CheckReturnValue public int totalSize()
public void unmark()
public void unmarkAll()
Copyright © 2003-2019 Serge Brisson. All Rights Reserved.