<"The Crow" <q>> wrote:
see my code above, can you see a hash table or "set" implementation. . dont
tell me doing so is more effective. because inserting to hashtable is costly
operration regarding to simply adding to array (btw i know array is not
arraylist.).
That entirely depends on how the array is implemented. Guess what? That
depends on the platform. You can't add to an array in .NET - they're a
fixed size. So, if you're actually after a JavaScript solution then
once again, I'll suggest you ask in the JS newsgroup.
and i wont do concurrent reads that will give me back lost cpu
cycles.. so hashtable is not efficient.
Have you benchmarked this to find out whether it's actually an issue?
Just how big is your array in real life anyway? It's not worth worrying
about efficiency if the simplest code works fast enough. (Not that I
believe your code is the simplest anyway, but anyway...)
Note that if you have a large array (which is the only time it would
actually matter), especially with a significant number of duplicates,
that would be more efficient - finding a match in a hashtable is faster
than having to loop through the array. Your solution is always O(n^2) -
a hashtable version would be O(n) I believe - according to MSDN, both
inserting into a hashtable and retrieving from it are O(1) operations.
If you're absolutely determined to use the O(n^2) solution, you could
at least call toLowerCase on aryTextInputs[i] *outside* the "j" loop -
you're currently lower-casing the same string every time. (In fact, you
might want to consider creating a separate array and lower-casing all
the values *once*, to avoid doing it within the loop at all.)
Anyway, it seems you've already decided that your solution is the best
one and you're unwilling to listen to my comments, so we might as well
call a halt here.
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too