Interface Shrinkable
- All Known Implementing Classes:
AbstractShrinkableList
,CappedList
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Interface for objects that can be resized to a smaller size in constant time. Classes should only implement this
interface if the resize reduces their scope from outside, meaning elements beyond the new size won't be visible
anymore.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
shrink
(int newSize) Shrinks the list to a new smaller size.
-
Method Details
-
shrink
int shrink(int newSize) Shrinks the list to a new smaller size. All elements at indices beyond the new size won't be visible anymore.- Parameters:
newSize
- the new size of the list- Returns:
- the old size of the list
- Throws:
IllegalArgumentException
- if the new size is negative or greater than the current size
-