automate tuple creation
forkit
forkit at gmail.com
Fri Jan 21 09:10:56 UTC 2022
On Friday, 21 January 2022 at 08:53:26 UTC, Stanislav Blinov
wrote:
>
turns out the problem has nothing to do with appender...
It's actually this line:
if (!idArray.canFind(x)):
when i comment this out in the function below, the program does
what I want in seconds.
only problem is, the ids are no longer unique (in the file)
// ---
void createUniqueIDArray
(ref int[] idArray, const(int) recordsNeeded)
{
idArray.reserve(recordsNeeded);
debug { writefln("idArray.capacity is %s", idArray.capacity);
}
int i = 0;
int x;
while(i != recordsNeeded)
{
// id needs to be 9 digits, and needs to start with 999
x = uniform(999*10^^6, 10^^9); // thanks Stanislav
// ensure every id added is unique.
//if (!idArray.canFind(x))
//{
idArray ~= x; // NOTE: does NOT appear to register
with -profile=gc
i++;
//}
}
debug { writefln("idArray.length = %s", idArray.length); }
}
// ----
More information about the Digitalmars-d-learn
mailing list