Fastest way to "ignore" elements from array without removal
z
z at z.com
Tue Feb 16 04:20:06 UTC 2021
What would be the overall best manner(in ease of implementation
and speed) to arbitrarily remove an item in the middle of an
array while iterating through it?
So far i've thought about simply using D's standard [0...x] ~
[x+1..$] with an array of indexes but wouldn't that just cause
slow reallocations? According to wikipedia the performance would
be suboptimal.[1]
I've also thought about using a pointer array and just assigning
a null pointer when the item doesn't need to be iterated on but
i'm not sure which method will result in the fastest execution
times for the general case where over half of the items will be
removed from the index/pointer array.
Big thanks
[1] - https://en.wikipedia.org/wiki/Dynamic_array#Performance
More information about the Digitalmars-d-learn
mailing list