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
public class PeekStack<T> extends ArrayList<T>
Stack object that allows easy verification of the values of the last few entries.Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.$LastChangedDate: 2015-07-26 01:01:13 +0200 (Sun, 26 Jul 2015) $, @version $Revision: 1155 $, by $Author: averbraeck $, initial version 24 jun. 2015
- Author:
- Peter Knoppers
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description PeekStack()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
peekNthLast(int offset)
Return the N-from-last element of this PeekStack.T
pop()
Pop an element off this stack.void
push(T element)
Push an element on this stack.boolean
topEntriesEqual(T... entries)
Check if the elements on the top of this PeekStack are equal to the provided entries.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
-
-
-
-
Method Detail
-
push
public final void push(T element)
Push an element on this stack.- Parameters:
element
- T; the element to push onto this stack
-
pop
public final T pop()
Pop an element off this stack.- Returns:
- T; the element that was popped of this stack
-
peekNthLast
public final T peekNthLast(int offset)
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
public final boolean topEntriesEqual(T... entries)
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
public final String toString()
- Overrides:
toString
in classAbstractCollection<T>
-
-