I have a Set
which stores IP addresses. The IP address could be a unique IP or a subnet. I have overloaded the __hash__
and __eq__
methods. The Set
works fine.
Question is : When I am trying to add a duplicate element, is there a way to show the original element?
I cannot use the in
operation because it will take a long time since there are about 100,000 IP addresses and I could create only like 5 different buckets for the Set
.
An example
I added the subnet 10.0.0.0/8 to the Set
.
I then tried to add the unique IP 10.10.10.10 to the Set
.
The Set
won't add the unique IP because it is a duplicate of the subset 10.0.0.0/8. At such a situation I want to show the user:
10.10.10.10 duplicate of 10.0.0.0/8
P.S : I just went through the definition of in
operation. It just shows if the element is already present or not. It won't show the original element. (I am not a python developer).
P.P.S : I am reading a firewall ACL list. I am adding lot more than just add IP address to the set. That is why I can't show the code here. The code works.