; docformat = 'rst' ;+ ; Find the difference of two sets of indices. A set of indices is ; represented by an array of non-negative integers where a scalar -1L ; indicates the empty set. ; ; :Returns: ; lonarr or -1L ; ; :Params: ; ind1 : in, required, type=lonarr or -1L ; array of indices where -1L indicates an empty set of indices ; ind2 : in, required, type=lonarr or -1L ; array of indices where -1L indicates an empty set of indices ;- function mg_setdifference, ind1, ind2 compile_opt strictarr min1 = min(ind1, max=max1) min2 = min(ind2, max=max2) ; empty set difference if ind1 is empty if (ind1[0] eq -1L) then return, -1L ; return ind1 if no intersection if ((min2 gt max1) || (max2 lt min1)) then return, ind1 r = where((histogram(ind1, min=min1, max=max1) ne 0L) and $ (histogram(ind2, min=min1, max=max1) eq 0), count) return, count eq 0L ? -1L : r + min1 end