Implementing Deque API.