|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface HashContainer
The root interface of sets and maps, based on hash tables.
Methods in this interface mostly regard to the specific operation on hash tables - rehash. During rehash, entries of this container are moved from the old table to the new one.
If the capacity of new table is greater than the old, such rehash is also referred as expansion or growth. It is performed when the hash container's load becomes too high, and operations' performance suffers, or it's simply no place to insert the new entries.
If the capacity of new table is lesser than the old, such rehash is also called
compaction or shrink. It could be performed automatically after hash container
construction, if the shrink condition of the hash
container's hash config triggers, or manually via shrink()
method. Shrink is useful for controlling hash container's memory consumption.
See Container
mutability matrix for methods
which are supported by hash containers with the specific mutability profile. All methods defined
in this interface directly are supported by hash containers with any mutability profile.
HashContainerFactory
Method Summary | |
---|---|
double |
currentLoad()
Returns fullness of the internal tables, the fraction of taken slots. |
boolean |
ensureCapacity(long minSize)
Prepares the hash for insertion of minSize - Container.size() new elements without
excessive rehashes. |
HashConfig |
hashConfig()
Returns the hash config which holds all "magic" parameters of this hash container: load and growth factors. |
boolean |
shrink()
If the current load is less than
hashConfig() . |
Methods inherited from interface com.koloboke.collect.Container |
---|
clear, isEmpty, size, sizeAsLong |
Method Detail |
---|
@Nonnull HashConfig hashConfig()
double currentLoad()
hashConfig()
.getMaxLoad()
,
expansion is triggered.
boolean ensureCapacity(long minSize)
minSize -
Container.size()
new elements without
excessive rehashes. Call of this method is a hint, but not a strict
guarantee that the next minSize - size()
insertions will be done in real time.
If minSize
is less than the current container size, the method returns
false
immediately.
ensureCapacity
in interface Container
minSize
- the desired minimum size, which the container is expected to reach soon
true
if rehash has been actually performed to ensure capacity,
and the next minSize - size()
insertions won't cause rehash for sure.
IllegalArgumentException
- if minSize
is negative
UnsupportedOperationException
- if the container doesn't support insertionsboolean shrink()
current load
is less than
hashConfig()
.getTargetLoad()
,
compaction is performed to fix this.
shrink
in interface Container
true
if the hash has been actually shrunk
UnsupportedOperationException
- if the container is immutable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |