ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.14k stars 439 forks source link

Rename adjacent_remove_if to unique_by? #176

Open ldionne opened 9 years ago

ldionne commented 9 years ago

While quickly skimming through the documentation, it occurred to me that view::adjacent_remove_if seems to do what a unique_by view might do. It is basically a view::unique but with a custom predicate. Thoughts?

CaseyCarter commented 9 years ago

My first reaction is that we shouldn't have a view::unique_by, because view::adjacent_remove_if should be an overload of view::unique's operator() that accepts predicate and projection arguments.

ldionne commented 9 years ago

I think you guys have a view::group_by, right? If so, maybe a view::group or view::grouped with an overload taking a predicate would also be more consistent/complete.

ldionne commented 9 years ago

Also, I personally prefer having a different *_by algorithm, but that's really just my own taste.

ericniebler commented 9 years ago

I was thinking that group_by was misnamed. Since it takes a binary predicate, it should probably be called group_if. Then group would use equality, and group_by would take a (unary) projection. But then again, maybe just group (takes an optional predicate and projection) and group_by (that takes just a projection) would do. Either way, group_by should probably change.