/*******************************************************************************
 * Copyright (c) 2010-2014 Alexander Kerner. All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package net.sf.jranges.range;

import java.util.Collection;

import net.sf.jranges.range.doublerange.DoubleRange;
import net.sf.jranges.range.integer.IntegerRange;
import net.sf.kerner.utils.math.UtilMath;

public class RangeUtils {

    public interface DoubleRangeTask {
        void call(double d);
    }

    public interface IntegerRangeTask {
        void call(int i);
    }

    public static void doForAllInRange(final DoubleRange range, final DoubleRangeTask task) {
        for (double i = range.getStart(); UtilMath.round(i, 6) <= range.getStop(); i += range.getInterval()) {
            task.call(i);
        }
    }

    public static void doForAllInRange(final IntegerRange range, final IntegerRangeTask task) {
        for (int i = range.getStart(); i <= range.getStop(); i += range.getInterval()) {
            task.call(i);
        }
    }

    public static boolean includesAll(final IntegerRange range, final Collection<? extends Integer> positions) {
        for (final int i : positions) {
            if (range.includes(i)) {
                // ok
            } else {
                return false;
            }
        }
        return true;
    }

    @Deprecated
    public static int startStayWithinLimit(final int value, final int limit) {
        if (value < limit)
            return limit;
        return value;
    }

    @Deprecated
    public static int stopStayWithinLimit(final int value, final int limit) {
        if (value > limit)
            return limit;
        return value;
    }

    private RangeUtils() {
    }
}

@@ -142,17 +142,16 @@
 rved.%0A *
- 
 %0A * Lice
@@ -323,17 +323,16 @@
 se at%0A *
- 
 %0A *   ht
@@ -374,17 +374,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -1338,32 +1338,49 @@
 op(); i += range
+%0A                
 .getInterval()) 
@@ -1373,32 +1373,32 @@
 etInterval()) %7B%0A
-
             task
@@ -1512,32 +1512,133 @@
 ngeTask task) %7B%0A
+        if (range == null %7C%7C task == null) %7B%0A            throw new NullPointerException();%0A        %7D%0A
         for (int
@@ -1745,32 +1745,32 @@
        %7D%0A    %7D%0A%0A
-
     public stati
@@ -1812,24 +1812,36 @@
 Range range,
+%0A           
  final Colle

Add null check.