04-19-2013, 06:28 PM
You know, a friend once said, "whitespace is free, so use it freely". You might want to take that advice as well
I hopefully fixed your code to compile on Linux, it had some really bad issues - you put a pointer into a list and then let the object it was pointing to die, etc. So I fixed that up, too. Also, a vector is a better data structure here, since you can more or less approximate the number of elements, so you can even pre-allocate it, thus saving quite a few reallocations; a list has to allocate each item, so it's slow.
I hopefully fixed your code to compile on Linux, it had some really bad issues - you put a pointer into a list and then let the object it was pointing to die, etc. So I fixed that up, too. Also, a vector is a better data structure here, since you can more or less approximate the number of elements, so you can even pre-allocate it, thus saving quite a few reallocations; a list has to allocate each item, so it's slow.