The deque data structure
The deque data structure, also known as the double-ended queue, is a special queue that allows us to insert and remove elements from the end or from the front of the deque.
A deque can be used to store a user's web browsing history. When a user visits a new page, it is added to the front of the deque. When the user navigates back, the most recent page is removed from the front, and when the user navigates forward, a page is added back to the front.
Another application would be an undo/redo feature. We learned we can use two stacks for this feature in the last chapter, but we can also use a deque as an alternative. User actions are pushed onto the deque, and undo operations pop actions off the front, while redo operations push them back on.