aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBen Gruver <bgruv@google.com>2012-12-29 14:50:15 -0800
committerBen Gruver <bgruv@google.com>2012-12-29 14:50:15 -0800
commit7d5439950fe52a7be4fa6cb222e301f78604f96f (patch)
tree25feef2e04abaa38a5b4c5338dae9fc18606b8c7 /util
parente77b5a7354f99f417f8d80df629d528e02ef5f9c (diff)
downloadsmali-7d5439950fe52a7be4fa6cb222e301f78604f96f.tar.gz
Fix various issues related to comparing method references.
Diffstat (limited to 'util')
-rw-r--r--util/src/main/java/org/jf/util/CollectionUtils.java22
1 files changed, 20 insertions, 2 deletions
diff --git a/util/src/main/java/org/jf/util/CollectionUtils.java b/util/src/main/java/org/jf/util/CollectionUtils.java
index 84de6953..23e23dc9 100644
--- a/util/src/main/java/org/jf/util/CollectionUtils.java
+++ b/util/src/main/java/org/jf/util/CollectionUtils.java
@@ -77,9 +77,18 @@ public class CollectionUtils {
@Nonnull Iterable<? extends T> it2) {
Iterator<? extends T> elements2 = it2.iterator();
for (T element1: it1) {
- int res = comparator.compare(element1, elements2.next());
+ T element2;
+ try {
+ element2 = elements2.next();
+ } catch (NoSuchElementException ex) {
+ return 1;
+ }
+ int res = comparator.compare(element1, element2);
if (res != 0) return res;
}
+ if (elements2.hasNext()) {
+ return -1;
+ }
return 0;
}
@@ -87,9 +96,18 @@ public class CollectionUtils {
@Nonnull Iterable<? extends T> it2) {
Iterator<? extends T> elements2 = it2.iterator();
for (T element1: it1) {
- int res = element1.compareTo(elements2.next());
+ T element2;
+ try {
+ element2 = elements2.next();
+ } catch (NoSuchElementException ex) {
+ return 1;
+ }
+ int res = element1.compareTo(element2);
if (res != 0) return res;
}
+ if (elements2.hasNext()) {
+ return -1;
+ }
return 0;
}