-
-
Method Summary
Modifier and Type Method Description final Integer
getSize()
final T
pop()
Pops the topmost element in this Stack. final T
popOrNull()
Pops the topmost element in this Stack. final List<T>
popAll(Integer numToPop)
Pops the n topmost elements in this Stack, where n is specified by the parameter. final List<T>
clear()
Pops all elements in this Stack and returns them in a List, with the topmost element as the list's head i.e. final Unit
push(T element)
Pushes the supplied element onto the Stack. final Unit
pushAll(Collection<T> elements)
Pushes all the supplied elements onto the Stack. final Unit
pushAll(T elements)
Pushes all the supplied elements onto the Stack. final T
peek()
Returns the topmost element in this Stack but does not pop it. final T
peekOrNull()
Returns the topmost element in this Stack but does not pop it. final List<T>
peekAll(Integer numToPeek)
Returns all elements in this Stack, with the last pushed Element at the highest index. final Integer
indexOf(T element)
Returns the index of the first occurrence of the specified element in the Stack, or -1 if the specified element is not contained in the Stack. final Boolean
isEmpty()
Returns whether this Stack is empty or not. final Boolean
isNotEmpty()
Returns whether this Stack is not empty. final Unit
shuffle()
Shuffles this Stack. final Unit
sort(Comparator<in T> comparator)
Sorts this Stack. -
-
Method Detail
-
popAll
final List<T> popAll(Integer numToPop)
Pops the n topmost elements in this Stack, where n is specified by the parameter. The topmost element in the stack gets the list's head i.e. index
0
.- Parameters:
numToPop
- Specifies how many elements to pop.
-
push
final Unit push(T element)
Pushes the supplied element onto the Stack.
- Parameters:
element
- The element to push onto this Stack.
-
pushAll
final Unit pushAll(Collection<T> elements)
Pushes all the supplied elements onto the Stack. The element at index 0 of the List is pushed first.
- Parameters:
elements
- The elements to push onto this Stack.
-
pushAll
final Unit pushAll(T elements)
Pushes all the supplied elements onto the Stack. The first parameter is pushed first.
- Parameters:
elements
- The elements to push onto this Stack.
-
peekOrNull
final T peekOrNull()
Returns the topmost element in this Stack but does not pop it.
-
peekAll
final List<T> peekAll(Integer numToPeek)
Returns all elements in this Stack, with the last pushed Element at the highest index.
-
isNotEmpty
final Boolean isNotEmpty()
Returns whether this Stack is not empty.
-
sort
final Unit sort(Comparator<in T> comparator)
Sorts this Stack.
- Parameters:
comparator
- Comparator for sorting.
-
-
-
-