Wednesday, 7 August 2013

Optimised arraylist

Optimised arraylist

I have this program that needs to do some comparisons of strings in an
array. The first thought one would have is of course to just use strcmp to
check whether two strings in the array are the same. Now consider the
option that you just need to compare the pointers to the strings. This
would involve some preparations to map each element that are literally the
same to the same place in memory.
I've done all this, by preparing with strcmp, and now with strstr (which I
believe is faster). But because I need to check every string to map them
to their first occurences, I get horribly long preparation-times. I should
mention that this array is several MB large.
So now to the question: Is there another way to do this kind of mapping
faster than I am already doing?

No comments:

Post a Comment