@SuppressWarnings({"rawtypes", "unchecked"})
    public static List<Interval<?>> complement(List<Interval> intervals) throws MIDDException {

        final Interval w = new Interval(new EndPoint(EndPoint.Infinity.NEGATIVE), new EndPoint(EndPoint.Infinity.POSITIVE));
        List<Interval<?>> op1 = new ArrayList<>();
        op1.add(w);

        for (Interval op2 : intervals) {
            final List<Interval<?>> result = new ArrayList<>();

            for (Interval item : op1) {
                if (item.isIntersec(op2)) {
                    final List<Interval<?>> l = item.complement(op2);
                    if (!l.isEmpty()) {
                        result.addAll(l);
                    }
                } else {
                    result.add(item);
                }
            }
            op1 = result;
        }
        return ImmutableList.copyOf(op1);
    }
@ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static List < Interval < ? > > complement ( List < Interval > intervals ) throws MIDDException { final Interval w = new Interval ( new EndPoint ( EndPoint . Infinity . NEGATIVE ) , new EndPoint ( EndPoint . Infinity . POSITIVE ) ) ; List < Interval < ? > > op1 = new ArrayList < > ( ) ; op1 . add ( w ) ; for ( Interval op2 : intervals ) { final List < Interval < ? > > result = new ArrayList < > ( ) ; for ( Interval item : op1 ) { if ( item . isIntersec ( op2 ) ) { final List < Interval < ? > > l = item . complement ( op2 ) ; if ( ! l . isEmpty ( ) ) { result . addAll ( l ) ; } } else { result . add ( item ) ; } } op1 = result ; } return ImmutableList . copyOf ( op1 ) ; }
Return the complement of list of intervals, i.e., (-inf, +inf) \ intervals

@param intervals
@return the immutable list of intervals that complement with the input