ArrayDeque
ArrayDeque is a resizable-array implementation of a double-ended queue (deque). It provides constant time insertion and removal at both ends and supports iteration. In Java, ArrayDeque is part of java.util and is intended as a high-performance replacement for LinkedList when a deque is needed. It does not permit null elements and is not thread-safe.
Internally, elements are stored in a circular array. The deque maintains indices for the head and tail.
Common operations include addFirst, addLast (or offerFirst, offerLast), removeFirst, removeLast (or pollFirst, pollLast), getFirst, getLast, peekFirst,
Because it uses an array and contiguous storage, it tends to have better locality and performance than