Returns true if each element in iterable after the first is greater than or equal to the element that preceded it, according to this ordering. Note that this is always true when the iterable has fewer than two elements.
(Iterable<? extends T> iterable)
| 922 | |
| 923 | |
| 924 | public boolean isOrdered(Iterable<? extends T> iterable) { |
| 925 | Iterator<? extends T> it = iterable.iterator(); |
| 926 | if (it.hasNext()) { |
| 927 | T prev = it.next(); |
| 928 | while (it.hasNext()) { |
| 929 | T next = it.next(); |
| 930 | if (compare(prev, next) > 0) { |
| 931 | return false; |
| 932 | } |
| 933 | prev = next; |
| 934 | } |
| 935 | } |
| 936 | return true; |
| 937 | } |
| 938 | |
| 939 | /** |
| 940 | * Returns {@code true} if each element in {@code iterable} after the first is |