Double ended queue (aka deque) implementation (untested).