When filling large collections, we have new: to set the expected capacity and new:withAll: to also define the objects to put in.
However, as we do not expose a collection's growth strategy, the use of new: gets tricky if one wants to avoid extra growth at all cost, e.g., when having millions of things.
The growth strategy is hidden within a collection's implementation.
A client would have to expose a best guess to avoid growth:
bigDatabase := IdentityDictionary new: allObjects size * 4 // 3 + 16.
Here numObjects * 4 // 3 + 16 is that guess. Maybe we want to offer a newForSizeNoGrow:.
When filling large collections, we have
new:to set the expected capacity andnew:withAll:to also define the objects to put in.However, as we do not expose a collection's growth strategy, the use of
new:gets tricky if one wants to avoid extra growth at all cost, e.g., when having millions of things.The growth strategy is hidden within a collection's implementation.
A client would have to expose a best guess to avoid growth:
Here
numObjects * 4 // 3 + 16is that guess. Maybe we want to offer anewForSizeNoGrow:.