completed Deque.java (untested)