Hashtable slowly adding values?

I am currently using Hashtable to store a list of unique identifiers and related data, all of which are read from a file.

The length of this data file can be very large: from 1 to several hundred thousand. I noticed a significant slowdown in the speed of adding entries to the Hashtable when about 50,000 entries passed.

I think setting the initial capacity may help, but obviously I can't know this number, as the data is being read from the file. Could someone suggest a way to speed up the addition of a large number of entries, or is this behavior pretty normal?

edit: Now I just use Hashtable. I think this should probably be Dictionary <string, MyDataObject>, but this seems like a separate issue.

+3
source share
1 answer

See here for a comparison of HashTables and dictionaries for a large number of items.

+2
source

Source: https://habr.com/ru/post/1716895/


All Articles