MCPcopy Index your code
hub / github.com/apache/groovy / peek

Method peek

src/main/java/groovy/lang/ObjectRange.java:518–542  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

516 }
517
518 private Comparable peek() {
519 if (step > 0) {
520 Comparable peekValue = value;
521 for (int i = 0; i < step; i++) {
522 peekValue = (Comparable) range.increment(peekValue);
523 // handle back to beginning due to modulo incrementing
524 if (range.compareTo(peekValue, range.from) <= 0) return null;
525 }
526 if (range.compareTo(peekValue, range.to) <= 0) {
527 return peekValue;
528 }
529 } else {
530 final int positiveStep = -step;
531 Comparable peekValue = value;
532 for (int i = 0; i < positiveStep; i++) {
533 peekValue = (Comparable) range.decrement(peekValue);
534 // handle back to beginning due to modulo decrementing
535 if (range.compareTo(peekValue, range.to) >= 0) return null;
536 }
537 if (range.compareTo(peekValue, range.from) >= 0) {
538 return peekValue;
539 }
540 }
541 return null;
542 }
543 }
544
545 /**

Callers 3

hasNextMethod · 0.95
nextMethod · 0.45

Calls 3

incrementMethod · 0.45
compareToMethod · 0.45
decrementMethod · 0.45

Tested by

no test coverage detected