On Friday, 21 January 2022 at 18:36:42 UTC, H. S. Teoh wrote:

This is wasteful if you're not planning to use every ID in this million-entry long array. Much better to just use an AA to keep track of which IDs have already been generated instead. Of course, if you plan to use most of the array, then the AA may wind up using more memory than the array. So it depends on your use case.


T

yes, I was thinking this over as I was waking up this morning, and thought... what the hell am I doing generating all those numbers that might never get used.

better to do:

const int iotaStartNum = 100_000_000;
int[] idArray = iota(startiotaStartNum, iotaStartNum + recordsNeeded).array;


Reply via email to