Exercise 3.23: Implement operations for deque