public class SimpleStack<T> extends Indexable.Base<T>
This class is not thread-safe, see FStack for a functional thread-safe implementation.
Indexable.Base<TT>, Indexable.IndexableSpliterator<TElem>, Indexable.ListView<T>EMPTY, EMPTY_INDEXABLE_STRING| Constructor and Description |
|---|
SimpleStack()
Create a stack.
|
SimpleStack(int initialSize)
Create a stack with the given initial size.
|
SimpleStack(java.lang.Iterable<? extends T> initialElements)
Create a stack with an initial set of elements.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<T> |
asList()
Get a view of this indexable as an unmodifiable list.
|
void |
clear()
Clear this stack.
|
T |
get(int index)
Get the element at the given index.
|
boolean |
isEmpty()
Is this indexable empty?
|
T |
peek()
Peek at the top-most stack element.
|
T |
peek(int index)
Peek at deeper elements.
|
T |
peekOrNull()
Peek at the top-most stack element.
|
T |
pop()
Pop the stack.
|
void |
push(T obj)
Push the stack down, and put the given object to the top of the stack.
|
int |
size()
Get the size.
|
void |
trim()
Trim this stack to the given size.
|
asBaseequals, hashCode, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddToArray, addToArray, addToCollection, asCollection, binarySearch, checkIndex, combine, compactCollector, compare, downCast, emptyIndexable, equal, fastCollector, findAll, findAllX, findFirst, findFirst, findFirst, findFirstX, findLast, findLast, findLast, findNext, findNext, findNext, findNextX, findPrevious, findPrevious, findPrevious, first, firstMatch, firstMatch, firstMatchX, forEachEntry, forEachEntryFragile, fromArray, fromCollection, fromCollection, fromCountable, fromCountable, fromEnumeration, fromEnumeration, fromIterable, fromIterable, fromIterable, fromIterable, fromIterator, fromList, fromOptional, frozenSpliterator, getMod, gyt, hash, headSet, indexedView, indexes, init, initByIndex, initFragile, intIndexes, isOrdered, isStrictlyOrdered, iterator, iterator, last, listIterator, mapArray, optional, ordered, reverse, rotated, singleton, spliterator, subSet, sybSet, tailSet, toString, view, view, viewArray, viewArray, viewAsBooleanIndexable, viewAsByteIndexable, viewAsCharIndexable, viewAsDict, viewAsDoubleIndexable, viewAsFloatIndexable, viewAsIntIndexable, viewAsLongIndexable, viewAsShortIndexable, viewByIndex, viewFragile, viewList, viewList, viewListN, viewListN, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, viewTuple, withAppendedItem, withCachedHash, withExchangedItemAt, withInsertedItemAt, withPrependedItem, withRemovedItemAt, withSwappedItemsAtaddAllTo, combined, combined, containsEq, containsRef, downCast, empty, equal, equals, filtered, filteredToIndexable, filterToCountable, firstOrNull, foldLeft, forEachFragile, freeze, frozen, frozen, getAny, groupingBy, groupingBy, hasAll, hasAny, isSorted, isStrictlySorted, lastOrNull, mappingBy, mappingBy, optFirst, optLast, orderedCombination, parallelStream, parellelStream, sorted, stream, toArray, toArray, toDict, toDict, toDict, toList, toString, uniform, viewCollection, viewCollection, viewCollectionN, viewCollectionN, withExchangedItempublic SimpleStack()
public SimpleStack(int initialSize)
initialSize - initial size of this stackpublic T get(int index)
Indexableindex - index between 0 and size() - 1public int size()
Sizeablepublic boolean isEmpty()
Indexabletrue: there are no elements in this indexablefalse: this indexable has elements@NotNull public java.util.List<T> asList()
IndexableCollection.addAll(Collection) (but have a look at
Countable.addAllTo(Collection)).Countable.toList()public T pop()
java.lang.IndexOutOfBoundsException - if this LIFO is emptypublic T peek()
java.lang.IndexOutOfBoundsException - if this LIFO is emptypeek(int),
peekOrNull()@Nullable public T peekOrNull()
null if this stack is empty.nullpublic T peek(int index)
index - index of the element from the top, with 0 giving the same result as peek()java.lang.IndexOutOfBoundsException - if index is out of rangepublic void push(T obj)
obj - object to be pushedpublic void trim()
public void clear()