MCPcopy Create free account
hub / github.com/antlr/codebuff / isOrdered

Method isOrdered

corpus/java/training/guava/collect/Ordering.java:910–923  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

908 * two elements.
909 */
910 public boolean isOrdered(Iterable<? extends T> iterable) {
911 Iterator<? extends T> it = iterable.iterator();
912 if (it.hasNext()) {
913 T prev = it.next();
914 while (it.hasNext()) {
915 T next = it.next();
916 if (compare(prev, next) > 0) {
917 return false;
918 }
919 prev = next;
920 }
921 }
922 return true;
923 }
924
925 /**
926 * Returns {@code true} if each element in {@code iterable} after the first is

Callers

nothing calls this directly

Calls 4

compareMethod · 0.95
iteratorMethod · 0.65
nextMethod · 0.65
hasNextMethod · 0.45

Tested by

no test coverage detected