[ https://issues.apache.org/jira/browse/GROOVY-11649?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17949643#comment-17949643 ]
Paul King commented on GROOVY-11649: ------------------------------------ Some additional examples: {code:groovy} // zero out the 4s int[] arr = [1, 2, 3, 3, 4, 4, 5, 6, 7] def low = arr.partitionPoint(0..-1) { it < 4 } def high = arr.partitionPoint(0..-1) { it <= 4 } Arrays.fill(arr, low, high, 0) assert arr == [1, 2, 3, 3, 0, 0, 5, 6, 7] // keep top 5 scores in top array int[] scores = [56, 82, 70, 74, 63, 92, 49, 69, 85, 79, 80, 82, 99, 95] int[] top = scores[0..4].sort() scores[5..-1].each { next -> def ins = top.partitionPoint{ it < next } - 1 if (ins > 0) { System.arraycopy(top, 1, top, 0, ins) } if (ins >= 0) { top[ins] = next } } assert top == [82, 85, 92, 95, 99] {code} > Create partitionPoint extension method variants > ----------------------------------------------- > > Key: GROOVY-11649 > URL: https://issues.apache.org/jira/browse/GROOVY-11649 > Project: Groovy > Issue Type: New Feature > Reporter: Paul King > Assignee: Paul King > Priority: Major > Fix For: 5.0.0-alpha-13 > > > See: https://github.com/apache/groovy/pull/2210 > * rust: > https://doc.rust-lang.org/std/primitive.slice.html#method.partition_point > * c++: https://en.cppreference.com/w/cpp/algorithm/ranges/partition_point > * python: https://docs.python.org/3/library/bisect.html#module-bisect -- This message was sent by Atlassian Jira (v8.20.10#820010)