public class SimpleCapacityPolicy extends java.lang.Object implements CapacityPolicy
CapacityPolicy
.
The calculation looks like
int newCapcity = (currentCapacity * 3) / 2 + 1
and it's only apply if currentCapacity is not greater or equals than requiredCapacity.
Constructor and Description |
---|
SimpleCapacityPolicy() |
Modifier and Type | Method and Description |
---|---|
int |
ensureCapacity(int requiredCapacity,
int currentCapacity)
Ensuring the currentCapacity is save to accommodate new items that
totally defined as requiredCapacity.
|
public int ensureCapacity(int requiredCapacity, int currentCapacity)
CapacityPolicy
ensureCapacity
in interface CapacityPolicy
requiredCapacity
- is the required capacity.currentCapacity
- is the current capacity.