-
Notifications
You must be signed in to change notification settings - Fork 72
Description
I think that a dedicated class to represent a Set<IPAddress>
would be quite useful.
It would be similar to a IPAddressSeqRange
, however the ip addresses do not have to be sequential.
An example use case of this would be ip address blocking. You would add zero or more ip address ranges or ip addresses to it, and then you would have a method to check if an ip address is contained in that set.
If any addresses are added to it, which are already in a sequential range in the datastructure, then it would not add it.
further, if any of the sequential ranges in the set are end-to-end or overlap, it would join then (as an example, using integers, if it contains 4-8 and 7-12, these would be joined so that it only stores 4-12). the same applies to adding an individual ip address (ie. if it contains 4-7 and 8 is added, then instead of inserting a new element into the underlying list, it just expands the 4-7 range to instead be 4-8)