groovy

List#indexOf(groovy.lang.Closure closure) and friends to groovy jdk

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.5.2
  • Component/s: groovy-jdk
  • Labels:
    None
  • Number of attachments :
    0

Description

find(groovy.lang.Closure closure) and findAll(groovy.lang.Closure closure) methods are really useful. It would be also good to have

List#indexOf(groovy.lang.Closure closure)
List#indexOf(int startIndex, groovy.lang.Closure closure) // startIndex tells from which index to start looking
int[] List#indicesOfAll(groovy.lang.Closure closure) // return type may also be a List<Integer> or whatever
List#lastIndexOf(groovy.lang.Closure closure)

in the groovy jdk as it is sometimes important to know where the elements fullfilling the given condition are in the list.

Activity

Hide
Paul King added a comment -

There was already a findIndexOf() method so I added findLastIndexOf() and findIndexValues(). All three variations take an optional start index.

Show
Paul King added a comment - There was already a findIndexOf() method so I added findLastIndexOf() and findIndexValues(). All three variations take an optional start index.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: