Ignore:
Timestamp:
2015-12-29T23:51:37+01:00 (4 years ago)
Author:
Don-vip
Message:

checkstyle, code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r9196 r9217  
    4848import java.util.List;
    4949import java.util.Locale;
     50import java.util.Objects;
    5051import java.util.concurrent.ExecutorService;
    5152import java.util.concurrent.Executors;
     
    515516    public static boolean equalsEpsilon(double a, double b) {
    516517        return Math.abs(a - b) <= EPSILON;
     518    }
     519
     520    /**
     521     * Determines if two collections are equal.
     522     * @param a first collection
     523     * @param b second collection
     524     * @return {@code true} if collections are equal, {@code false} otherwise
     525     * @since 9217
     526     */
     527    public static boolean equalCollection(Collection<?> a, Collection<?> b) {
     528        if (a == null) return b == null;
     529        if (b == null) return false;
     530        if (a.size() != b.size()) return false;
     531        Iterator<?> itA = a.iterator();
     532        Iterator<?> itB = b.iterator();
     533        while (itA.hasNext()) {
     534            if (!Objects.equals(itA.next(), itB.next()))
     535                return false;
     536        }
     537        return true;
    517538    }
    518539
Note: See TracChangeset for help on using the changeset viewer.