This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new f1b3f727ed GROOVY-11649: Create partitionPoint extension method 
variants (minor refactor - use subListBorders)
f1b3f727ed is described below

commit f1b3f727ed9a94ab314241449ae875cf7355ffe8
Author: Paul King <[email protected]>
AuthorDate: Tue May 6 16:36:50 2025 +1000

    GROOVY-11649: Create partitionPoint extension method variants (minor 
refactor - use subListBorders)
---
 .../groovy/runtime/ArrayGroovyMethods.java         | 252 ++++++++++-----------
 .../groovy/runtime/DefaultGroovyMethods.java       |  44 ++--
 2 files changed, 149 insertions(+), 147 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java 
b/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
index d11be9d804..27ef270a16 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ArrayGroovyMethods.java
@@ -6594,31 +6594,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as Integer[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy arr
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static <T> int partitionPoint(T[] self, IntRange intRange, 
Predicate<T> condition) {
+    public static <T> int partitionPoint(T[] self, IntRange range, 
Predicate<T> condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -6642,23 +6642,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as Integer[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static <T> int partitionPoint(T[] self, Predicate<T> condition) {
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     /**
@@ -6672,31 +6672,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as char[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy arr
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static int partitionPoint(char[] self, IntRange intRange, 
IntPredicate condition) {
+    public static int partitionPoint(char[] self, IntRange range, IntPredicate 
condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -6720,23 +6720,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as char[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static int partitionPoint(char[] self, IntPredicate condition) {
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     /**
@@ -6750,31 +6750,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as short[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy arr
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static int partitionPoint(short[] self, IntRange intRange, 
IntPredicate condition) {
+    public static int partitionPoint(short[] self, IntRange range, 
IntPredicate condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -6798,23 +6798,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as short[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static int partitionPoint(short[] self, IntPredicate condition) {
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     /**
@@ -6828,31 +6828,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as int[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy arr
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static int partitionPoint(int[] self, IntRange intRange, 
IntPredicate condition) {
+    public static int partitionPoint(int[] self, IntRange range, IntPredicate 
condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -6876,23 +6876,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as int[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static int partitionPoint(int[] self, IntPredicate condition) {
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     /**
@@ -6906,31 +6906,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as long[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy arr
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static int partitionPoint(long[] self, IntRange intRange, 
LongPredicate condition) {
+    public static int partitionPoint(long[] self, IntRange range, 
LongPredicate condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -6954,23 +6954,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as long[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static int partitionPoint(long[] self, LongPredicate condition) {
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     /**
@@ -6984,31 +6984,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as float[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy arr
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static int partitionPoint(float[] self, IntRange intRange, 
DoublePredicate condition) {
+    public static int partitionPoint(float[] self, IntRange range, 
DoublePredicate condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -7032,23 +7032,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as float[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static int partitionPoint(float[] self, DoublePredicate condition) {
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     /**
@@ -7062,31 +7062,31 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as double[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint(0..<arr.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint(0..<arr.size()) { it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 100 } == arr.size()
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint(0..<arr.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for no match condition with range
      * assert arr.partitionPoint(2..<arr.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy array
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range     the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static int partitionPoint(double[] self, IntRange intRange, 
DoublePredicate condition) {
+    public static int partitionPoint(double[] self, IntRange range, 
DoublePredicate condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.length);
+        RangeInfo info = range.subListBorders(self.length);
+        Objects.checkFromToIndex(info.from, info.to, self.length);
 
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt() ;
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self[mid])) {
@@ -7110,23 +7110,23 @@ public class ArrayGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] as double[]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case like lower_bound(cpp), bisect_left(python)
      * assert arr.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case like upper_bound(cpp), bisect_right(python)
      * assert arr.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert arr.partitionPoint{ it <= 100 } == arr.size()
-     * //for none match condition
+     * // for no match condition
      * assert arr.partitionPoint{ it <= 0 } == 0
      * </pre>
      *
      * @param self      a groovy arr
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static int partitionPoint(double[] self, DoublePredicate condition) 
{
-        return partitionPoint(self, new IntRange(0, self.length - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.length - 1), 
condition);
     }
 
     
//--------------------------------------------------------------------------
diff --git 
a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java 
b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index bb935c666c..761ccb6c2f 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -11062,30 +11062,32 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      *
      * <pre class="groovyTestCase">
      * def list = [1, 2, 3, 3, 4, 4, 5, 6, 7]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case as lower_bound(cpp), bisect_left(python)
      * assert list.partitionPoint(0..<list.size()) { it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case as upper_bound(cpp), bisect_right(python)
      * assert list.partitionPoint(0..<list.size()) { it <= 4 } == 6
-     * //for all match condition
-     * assert list.partitionPoint(0..<list.size()) { it <= 100 } == list.size()
-     * //for none match condition
+     * // for all match condition
+     * assert list.partitionPoint(0..<list.size()) { it <= 20 } == list.size()
+     * // for no match condition
      * assert list.partitionPoint(0..<list.size()) { it <= 0 } == 0
-     * //for none match condition with range
+     * // for all match condition with range
+     * assert list.partitionPoint(0..<4) { it <= 20 } == 4
+     * // for no match condition with range
      * assert list.partitionPoint(2..<list.size()) { it <= 0 } == 2
      * </pre>
      *
      * @param self      a groovy list
-     * @param intRange  the range [l,r] to find data match the condition
+     * @param range  the range [l,r] to find data match the condition
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
-    public static <T> int partitionPoint(List<T> self, IntRange intRange, 
Predicate<T> condition) {
+    public static <T> int partitionPoint(List<T> self, IntRange range, 
Predicate<T> condition) {
         Objects.requireNonNull(self);
-        assert !intRange.isReverse();
-        Objects.checkFromToIndex(intRange.getFromInt(),intRange.getToInt(), 
self.size());
-        int result = intRange.getFromInt();
-        int left = intRange.getFromInt(), right = intRange.getToInt();
+        RangeInfo info = range.subListBorders(self.size());
+        Objects.checkFromToIndex(info.from, info.to, self.size());
+        int result = info.from;
+        int left = info.from, right = info.to - 1;
         while (left <= right) {
             int mid = left + (right - left) / 2;
             if (condition.test(self.get(mid))) {
@@ -11103,21 +11105,21 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      * (the index of the first element of the second partition).
      * The list is assumed to be partitioned according to the given predicate.
      * <pre class="groovyTestCase">
-     * def list = [7, 15, 3, 5, 4, 12, 6]
+     * def list = [7, 15, 3, 5, 4, 12, 6] // partitioned into odds then evens
      * assert list.partitionPoint{ it%2 != 0 } == 4
      * </pre>
      *
      * <pre class="groovyTestCase">
      * def list = [1, 2, 3, 3, 4, 4, 5, 6, 7]
-     * //usage case as lowerBound(cpp), bisect_left(python)
+     * // usage case as lower_bound(cpp), bisect_left(python)
      * assert list.partitionPoint{ it < 4 } == 4
-     * //usage case as upperBound(cpp), bisect_right(python)
+     * // usage case as upper_bound(cpp), bisect_right(python)
      * assert list.partitionPoint{ it <= 4 } == 6
-     * //for all match condition
+     * // for all match condition
      * assert list.partitionPoint{ it <= 100 } == list.size()
-     * //for none match condition
+     * // for no match condition
      * assert list.partitionPoint{ it <= 0 } == 0
-     * //predicate of reverse logic examples:
+     * // predicate of reverse logic examples:
      * assert [7, 6, 5, 4, 4, 3, 3, 2, 1].partitionPoint{ it > 4 } == 3
      * assert [7, 6, 5, 4, 4, 3, 3, 2, 1].partitionPoint{ it >= 4 } == 5
      * </pre>
@@ -11125,10 +11127,10 @@ public class DefaultGroovyMethods extends 
DefaultGroovyMethodsSupport {
      * @param self      a groovy list
      * @param condition the matching condition
      * @return an integer that is the index of the first element of the second 
partition
-     * @since 5.0
+     * @since 5.0.0
      */
     public static <T> int partitionPoint(List<T> self, Predicate<T> condition) 
{
-        return partitionPoint(self, new IntRange(0, self.size() - 1), 
condition);
+        return partitionPoint(self, new IntRange(true, 0, self.size() - 1), 
condition);
     }
 
     
//--------------------------------------------------------------------------

Reply via email to