开发者

.NET values lookup

I have a feeling of missing something obvious. UDP receiver application. It holds a collection of valid UDP sender IPs - only guys with IP on that list will be considered. Since that list must be looked at on every packet and UDPs are so volatile, that operation must be maximum fas开发者_如何转开发t. Good choice is Dictionary but it is a key-value structure and what I actually need here is a dictionary-like (hash lookup) key only structure. Is there something like that? Small annoyance rather than a bug but still. I can still use Dictionary

Thanks, M.


Perhaps you want HashSet<T>. It is like a dictionary but only stores the key as the value.


You can use HashSet<T> if on .NET 3.5, or Dictionary<T, object>, storing null in all the values, for .NET 2. This will give you O(1) lookup & retrieval time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜