3 ms·
This isn't a case of a memory management issue. It's a case of someone using an O(n) algorithm instead of O(1). There's not a memory layout that would change th
by MichaelGG 12y ago
This isn't a case of a memory management issue. It's a case of someone using an O(n) algorithm instead of O(1). There's not a memory layout that would change this. Even if you used an array, if you iterated over it, it'd still be rather expensive.
This is also what abstractions are for. Instead of killing your perf by using an unsuitable data structure, implement the same interface, but with a fast implementation. Using linked list for this scenario seems suboptimal.