Is HashSet the fastest container to look up in?

后端 未结 2 849
庸人自扰
庸人自扰 2021-02-04 08:30

I need to check that specific string contains in the set of others:

private bool Contains(string field)
{
   return this.Fields.Contains(field); // HashSet

        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-04 09:25

    Yes, HashSet is perfect for this since it contains one value to look up unlike a Dictionary which requires a key and a value.

提交回复
热议问题