Is there an unsynchronized version of java.util.Stack
?
ArrayList
almost has everything I want, except there doesn't seem to be a method that removes last element in amortized constant time.
I want something that can act like a stack, but still let me have constant random access to the elements.
If there really isn't anything, it isn't a big deal for me to just roll out my own or just use java.util.Stack
, but it seemed strange to me that I couldn't find Stack
's non-synchronized counterpart, that I thought it might be worth asking (also Googling just seemed to point me to other implementations rather than a class in the standard library).
When the Collections framework was expanded, Stack
was replaced by the interface Deque
. It supports the same push
, pop
, and peek
methods of Stack
.
Implementations of Deque
include ArrayDeque
and LinkedList
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With