dnrajugade / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Add Iterables.compare() #1182

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently there is usefull Iterables.elementsEqual(Iterable<?>, Iterable<?>) 
that checks for equality.
Consider adding
<E extends Comparable<? super E>> int Iterables.compare(Iterable<? extends E>, 
Iterable<? extends E>) that compares elements. Also, maybe a version with 
comparator too.

Original issue reported on code.google.com by Ash2kk@gmail.com on 1 Nov 2012 at 6:40

GoogleCodeExporter commented 9 years ago
My usecase:
I'm writing a comparator for a class that have List<String> field and want to 
compare this fields.

Original comment by Ash2kk@gmail.com on 1 Nov 2012 at 6:41

GoogleCodeExporter commented 9 years ago
What about Ordering.lexicographical() ?
Comparable version is doable via Ordering.natural().lexicographical(),
Comparator version via Ordering.from(yourComparator).lexicographical().

Original comment by tomas.za...@gmail.com on 1 Nov 2012 at 7:55

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by Ash2kk@gmail.com on 1 Nov 2012 at 8:38

GoogleCodeExporter commented 9 years ago

Original comment by cpov...@google.com on 1 Nov 2012 at 2:45

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08