Swaps an element with the deque's last 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 1)) ; prints b
(prn st) ; prints aecd