v3.2.0
- Introduce Map/MapOf configs and grow-only option (#132)
Adds options support to the NewMap
/NewMapOf
functions. A MapOf
can now be created like this:
m := xsync.NewMapOf[int, int](WithPresize(100))
NewPresizedMap
/NewPresizedMapOf
functions are deprecated. Use the WithPresize
option instead.
Also, adds WithGrowOnly
option. It configures new Map
/MapOf
instance to be grow-only. This means that the underlying hash table grows in capacity when new keys are added, but does not shrink when keys are deleted. The only exception to this rule is the Clear
method which shrinks the hash table back to the initial capacity.
Grow-only maps are more efficient in the case of oscillating map size, i.e. when the map frequently grows and then shrinks in size.