Class PeekStack<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<T>
org.opentrafficsim.road.network.factory.PeekStack<T>
- Type Parameters:
T
- type of the objects stored on this PeekStack
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,List<T>
,RandomAccess
Stack object that allows easy verification of the values of the last few entries.
Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Peter Knoppers
- See Also:
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal T
peekNthLast
(int offset) Return the N-from-last element of this PeekStack.final T
pop()
Pop an element off this stack.final void
Push an element on this stack.final boolean
topEntriesEqual
(T... entries) Check if the elements on the top of this PeekStack are equal to the provided entries.final String
toString()
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll
-
Constructor Details
-
PeekStack
public PeekStack()
-
-
Method Details
-
push
Push an element on this stack.- Parameters:
element
- T; the element to push onto this stack
-
pop
Pop an element off this stack.- Returns:
- T; the element that was popped of this stack
-
peekNthLast
Return the N-from-last element of this PeekStack.- Parameters:
offset
- int; if 0 the last pushed, but not yet popped element is returned; if offset is 1, the before last pushed, but not yet popped element is returned; etc.- Returns:
- T; the addressed element
-
topEntriesEqual
Check if the elements on the top of this PeekStack are equal to the provided entries.- Parameters:
entries
- T...; the provided entries- Returns:
- boolean; true if this PeekStack contains, at the top, the provided entries in the specified order; false otherwise
-
toString
- Overrides:
toString
in classAbstractCollection<T>
-