What is the best way and best collection to find out if collection contains string

I have collection, that contains strings of length 9. I process strings, but for every string I process, I add about 80 new strings to the collection, I stop after x processed strings.

In every run, I need to check if collection contains string – about 80 times. The problem is, that when I have about 1450 strings in collection (18th iteration), one iteration takes about 3 seconds (at start, it takes about 200 ms).

How can I make this faster? I use HashSet and HashSet.Add() method to add new string and check if the new string exists in HashSet at one time.

submitted by /u/SoptikHa
[link] [comments]

Leave a Reply