Python's collections.deque has a maxlen argument, such that
[...] the deque is bounded to the specified maximum length. Once a bounded length deque is full, when new items are added, a corresponding number of items are discarded from the opposite end. [...]
I have been looking for a class that implements the Deque interface in Java, that does the same.
public ArrayDeque(int numElements) looks like numElements only initializes the deque to that size, but doesn't enforce it as a max length.
 
    