Item type.
Retrieves the item at the given index.
Supports negative indices (-1 = tail). Non-integers are truncated toward zero.
Position in the deque.
The item, or null if out of range.
Appends items to the tail.
Items to append (in order).
The new length.
Inserts items at the head.
Items to insert; first argument becomes the new head.
The new length.
A double-ended queue with amortized O(1) insertion and removal at both ends.
Uses a sparse index map so head and tail grow independently without array shifts.
Example