Just use ArrayDeque.