implements deque (queue/stack)