Class CappedList<E>

java.lang.Object
Type Parameters:
E - the type of the elements in this list
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, RandomAccess, SequencedCollection<E>, Shrinkable

public class CappedList<E> extends AbstractShrinkableList<E> implements List<E>, RandomAccess, Shrinkable
Random-Access List implementation with a fixed capacity. This list can be used whenever the maximum size of a list is known in advance, making dynamic growth unnecessary.

Although the capacity is fixed, the list behaves as if it was dynamic. This means that methods like add are available, but will throw an IllegalStateException if the list is full. Adding elements to a full CappedList should therefore usually be avoided.

Some use cases for this list are datastructures that are limited due to real-world constraints or datastructures that get (partially) cleared on a regular basis.

Author:
Paul Steinbach
See Also: