Swaps an element with the deque's first element, then removes it and returns it.
Unlike remove!
, this is O(1)
. However, the deque's ordering
is not necessarily preserved.
(let st (clone "abcde"))
(prn (swap-remove! st 3)) ; prints d
(prn st) ; prints bcae