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:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.List<T>
,java.util.RandomAccess
public class PeekStack<T>
extends java.util.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
-
Constructor Summary
Constructors Constructor Description PeekStack()
-
Method Summary
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.java.lang.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
-
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
public final java.lang.String toString()- Overrides:
toString
in classjava.util.AbstractCollection<T>
-