public interface CapacityManagement
Modifier and Type | Method and Description |
---|---|
boolean |
ensureAdditionalCapacity(int additionalCapacity)
Ensures that the internal storage has room for at least the provided number of additional elements.
|
boolean |
ensureCapacity(int minCapacity)
Ensures that the internal storage has room for at least the provided number of elements.
|
void |
hintNextCapacity(int nextCapacityHint)
Gives a hint regarding the capacity that should be reserved when resizing the internal storage for the next time.
|
boolean ensureCapacity(int minCapacity)
minCapacity
- the minimal number of elements the storage should have room for.true
iff the internal storage had to be resized, false
otherwise.boolean ensureAdditionalCapacity(int additionalCapacity)
Calling this method is equivalent to calling the above ensureCapacity(int)
with an argument of
size() + additionalCapacity
.
additionalCapacity
- the number of additional elements the storage should have room for.true
iff the internal storage had to be resized, false
otherwise.void hintNextCapacity(int nextCapacityHint)
ensureCapacity(int)
, i.e. it reserves the specified capacity at the time
the next resizing of the internal storage is performed.
This method is useful when a not too imprecise upper bound on the elements that will in consequence be added is
known. Since the actual number of elements added may be lower than the specified upper bound, a resizing that
would have been performed by ensureCapacity(int)
might not be necessary.
nextCapacityHint
- the next capacity hint.Copyright © 2020. All rights reserved.