Is it possible to pass a comparator to Collections.disjoint? In the documentation I couldn't find a variation of the method to be accepting comparator, or am I missing something?
Collections.disjoint(c1, c2);
I can see in Collections documentation that sort (method of Collections) has two versions, one with comparator and one without:
sort(List<T> list)
sort(List<T> list, Comparator<? super T> c)
This answer lies somewhere between a comment and a full-blown answer, but I believe the reason that Collections.disjoint()
does not expose the possibility of using a custom comparator is that it doesn't use a comparator to compute the disjoint between two collections.
From the Javadoc:
public static boolean disjoint(Collection c1, Collection c2)
Returns true if the two specified collections have no elements in common.
The method which is used to determine if two elements are "in common" is the equals()
method of each entry in the collection. On the other hand, in Java a comparator is typically used to determine the relative ordering of two elements in a collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With