Skip to content

v3.2.0

Compare
Choose a tag to compare
@puzpuzpuz puzpuzpuz released this 22 Jun 05:43
· 9 commits to main since this release
ec68f42
  • 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.