TOP KEK
TOP KEK

Reputation: 2661

Data structure to store ip addresses

What is the best data structure to store a list of client's ip addresses?

I think there are no any strict limitations on memory size or lookup speed since it is a ip address filter application.

I was thinking about dictionary, but probably it is gives too much overhead for storing such a simple thing as unique list of addresses. Hashtable is essentially based on dictionaries as well.

Array is not good because you have to allocate too much space even for storing few addresses. List is not unique.

Upvotes: 0

Views: 1819

Answers (2)

BlueM
BlueM

Reputation: 6888

If you want uniqueness you can use

HashSet<IPAddress>

Upvotes: 1

Wasif Hossain
Wasif Hossain

Reputation: 3950

You can give HashSet<T> a try!

Upvotes: 1

Related Questions