是的HashSet< T>最快的容器来查找吗? [英] Is HashSet<T> the fastest container to look up in?

查看:127
本文介绍了是的HashSet< T>最快的容器来查找吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查特定的字符串包含了一系列其他的:

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

private bool Contains(string field)
{
   return this.Fields.Contains(field); // HashSet<string> local property
}

什么是容器的最佳类型使用,如果只有一个任务呢? - 把若干个字符串,并检查是否另一个是进入或不

What is the best type of container to use if only one task of it - to hold a number of strings and check does another one is into or does not?

推荐答案

是的,HashSet的是为这个完美的,因为它包含一个值来查找不像字典,需要一个键和一个值。

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

这篇关于是的HashSet&LT; T&GT;最快的容器来查找吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆