.net - C#, List<T>.Contains() - too slow? -
Can anyone explain to me why the function () in the generic list is very slow?
I have a list of millions of numbers and the code which is a specific number within this number is constantly checking.
I tried to do the same thing using the dictionary and () function of the containing, and it was 10-20 times faster than the list. Of course, I really do not want to use the dictionary for that purpose, because it does not mean that it should be used.
Therefore, the real question is that there is no alternative to the list. (), But not as whacky as the dictionary. Bracket (?) ?? Thanks in advance thanks!
If you are just checking for existence, then hashaseet and lt; T & gt; is your best option - display like a dictionary, but there is no key / value pair - just value:
hashaseet & lt; Int & gt; Data = new hashset & lt; Int & gt; (); {Data.Add (rand.ext (50000000)) for (Int i = 0; I & lt; 1000000; i ++); } Is in Bool = data Canton (1234567); // etc
Comments
Post a Comment