Java Collection Equal equals(Collection a, Collection b, boolean ordered)

Here you can find the source of equals(Collection a, Collection b, boolean ordered)

Description

equals

License

Apache License

Declaration

private static <T> boolean equals(Collection<T> a, Collection<T> b, boolean ordered) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.Collection;

import java.util.List;

public class Main {
    private static <T> boolean equals(Collection<T> a, Collection<T> b, boolean ordered) {
        if (a == null)
            return b == null;
        else if (b == null)
            return a == null;
        else if (a.size() != b.size())
            return false;
        else if (ordered)
            return a.equals(b);
        else {//from  w w w  .  j a va2  s. c  o m
            List<T> list = new ArrayList<T>(a);
            for (T t : b) {
                if (!list.remove(t))
                    return false;
            }
            return true;
        }
    }
}

Related

  1. equalContent(Collection col1, Collection col2)
  2. equalContent(final Collection a, final Collection b)
  3. equals(Collection c1, Collection c2)
  4. equals(Collection collection1, Collection collection2)
  5. equals(Collection collection1, Collection collection2)
  6. equals(final Collection c1, final Collection c2)
  7. equals(Iterable collection1, Iterable collection2)
  8. equalsAny(Object object, Collection objects)
  9. equalsCollectionsAnyOrder(Collection i1, Collection i2)

  10. HOME | Copyright © www.java2s.com 2016