Best Collection for Fast String Lookup

后端 未结 7 1674
别跟我提以往
别跟我提以往 2020-12-30 22:28

I need a list of strings and a way to quickly determine if a string is contained within that list.

To enhance lookup speed, I considered SortedList and

7条回答
  •  无人及你
    2020-12-30 23:05

    This sounds like a job for

     var keys = new HashSet();
    

    Per MSDN: The Contains function has O(1) complexity.

    But you should be aware that it does not give an error for duplicates when adding.

提交回复
热议问题