views:

68

answers:

2
+1  Q: 

.NET values lookup

Hi,

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 fast. 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.

+6  A: 

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

LBushkin
Thank you! I knew it was obvious :-)
Maciej
+4  A: 

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.

thecoop
That answer is good too, thanks.
Maciej