cmp method
Lexicographically compares the elements of this Iterator with those of another. Less = -1 Equal = 0 Greater = 1
Implementation
int cmp(Iterator<U> other) {
while (true) {
if (moveNext()) {
if (other.moveNext()) {
final cmp = current.compareTo(other.current);
if (cmp != 0) {
return cmp;
}
} else {
return 1;
}
} else {
if (other.moveNext()) {
return -1;
} else {
return 0;
}
}
}
}