Skip to content

Add IterableOps.groupFlatMap method #135

Open
@ashleymercer

Description

@ashleymercer

We already have IterableOps.groupMap and groupMapReduce methods, does it make sense to add a groupFlatMap method as well?

In the simplest case this could just be an alias for groupMapReduce(f)(g)(_ ++ _) but if implemented separately it can be more efficient:

  • we can avoid an extra function call to the reducer "wrapper" function for each element
  • we can use a mutable buffer internally to build up the list of values

Indeed groupMapReduce already states in its doc that it exists (solely?) because it's more efficient than rolling the behaviour by hand using groupBy(f).map(...). It also somehow "feels" like this is missing from the API since we generally expect map and flatMap to come as a pair.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions