Here you can find the source of isEquals(Collection
Parameter | Description |
---|---|
set1 | a parameter |
set2 | a parameter |
public static <E> boolean isEquals(Collection<E> set1, Collection<E> set2)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**/*from ww w. j a v a 2 s . c om*/ * @param set1 * @param set2 * @return true: Set1 has the same elements of Set2 */ public static <E> boolean isEquals(Collection<E> set1, Collection<E> set2) { if (set1.size() == set2.size()) { return isSubset(set1, set2); } return false; } /** * Verify if a set is subset of other set * * @param subSet * @param superSet * @return */ public static <E> boolean isSubset(Collection<E> subSet, Collection<E> superSet) { int occurrenceCount = 0; if (subSet != null && superSet != null) { for (E subSetElement : subSet) { if (superSet.contains(subSetElement)) { occurrenceCount++; } } if (occurrenceCount == subSet.size()) { return true; } } return false; } }