I've been looking for a method that operates like Arrays.equals(a1, a2)
, but ignoring the element order. I haven't been able to find it in either Google Collections (something like Iterables.elementsEqual()
, but that does account for ordering) and JUnit (assertEquals()
obviously just calls equals()
on the Collection, which depends on the Collection implementation, and that's not what I want)
It would be best if such a method would take Iterable
s, but I'm also fine with simply taking Collection
s
Such a method would of course take into account any duplicate elements in the collection (so it can't simply test for containsAll()
).
Note that I'm not asking how to implement such a thing, I was just wondering if any of the standard Collections libraries have it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…