#NEWLINE# def intersection( self , other ) : #NEWLINE# #INDENT# '\n        :param other: an IP set.\n\n        :return: the intersection of this IP set and another as a new IP set.\n            (IP addresses and subnets common to both sets).\n        ' #NEWLINE# result_cidrs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# own_nets = sorted ( self . _cidrs ) #NEWLINE# other_nets = sorted ( other . _cidrs ) #NEWLINE# own_idx = 0 #NEWLINE# other_idx = 0 #NEWLINE# own_len = len ( own_nets ) #NEWLINE# other_len = len ( other_nets ) #NEWLINE# while ( ( own_idx < own_len ) and ( other_idx < other_len ) ) : #NEWLINE# #INDENT# own_cur = own_nets [ own_idx ] #NEWLINE# other_cur = other_nets [ other_idx ] #NEWLINE# if ( own_cur == other_cur ) : #NEWLINE# #INDENT# result_cidrs [ own_cur ] = True #NEWLINE# own_idx += 1 #NEWLINE# other_idx += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( own_cur in other_cur ) : #NEWLINE# #INDENT# result_cidrs [ own_cur ] = True #NEWLINE# own_idx += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( other_cur in own_cur ) : #NEWLINE# #INDENT# result_cidrs [ other_cur ] = True #NEWLINE# other_idx += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( own_cur < other_cur ) : #NEWLINE# #INDENT# own_idx += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# other_idx += 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# result = IPSet ( ) #NEWLINE# result . _cidrs = result_cidrs #NEWLINE# return result