dongwq commented on PR #2210:
URL: https://github.com/apache/groovy/pull/2210#issuecomment-2849075039

   > This is an interesting proposal.
   > 
   > One immediate point of feedback is I would change the IntRange semantics 
to follow normal Groovy idioms. I know that means it might be slightly 
different to rust and other languages, but it follows what we do for all other 
Groovy methods. So, basically you'd get rid of the "- 1" when accessing 
getToInt() and change your examples from "0..arr.size()" to "0..<arr.size()" or 
"0..-1". Groovy let's you pick between (l, r), [l, r), [l, r] etc by using 
0<..<4, 1..<4, 1..3 etc. I also haven't checked yet whether reverse ranges are 
handled properly, but perhaps you've already considered that.
   > 
   > Also, Java doesn't have a sorted list but offers Collections.sort(). 
Groovy doesn't have partition (currently) but does have groupBy. So, I think it 
makes sense to discuss in more detail how this would typically be used. Is it 
less useful than in other languages given the JDK collection semantics or is 
other functionality needed (like a partition extension method) to reap the full 
benefits. I think discussing such things is best on the mailing list or the 
issue.
   
   @paulk-asert  Thank you 
   - the range arg: have adjusted to normal Groovy idioms.
   - reverse ranges: with an assert check
   - the usage: here partition_point can be view as a modern/general vision api 
of binary search with the help of closure/lambda. old binarySearch in java , 
lack of the ability to process these cases:
      1. directly provide the postion for insert like: lowerBound/uppperBound 
      2. the result of ordered arr/list with one val occured more than once is 
uncertain.
      
   after all, so I change the method name to binaryPartitionPoint to be more 
precise.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to