Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: x/exp/xiter: add IsSorted/IsSortedFunc #67457

Open
leaxoy opened this issue May 17, 2024 · 2 comments
Open

proposal: x/exp/xiter: add IsSorted/IsSortedFunc #67457

leaxoy opened this issue May 17, 2024 · 2 comments
Labels
Milestone

Comments

@leaxoy
Copy link

leaxoy commented May 17, 2024

Proposal Details

Proposed add below functions:

func IsSorted[E cmp.Ordered](s Seq[E])

func IsSortedFunc[E any](s Seq[E], f func(E, E) int)
@Merovius
Copy link
Contributor

If the IsSortedFunc is added, the comparator should be a three-way comparison, for the same reason that slices.IsSortedFunc and slices.SortStableFunc use it:

func IsSortedFunc[E any](s iter.Seq[E], cmp func(E, E) int)

for similar reasons as with #67458 I'm not sure about the utility of these: Checking if a sequence is sorted while also throwing it away seems kind of rarely useful.

@leaxoy
Copy link
Author

leaxoy commented May 22, 2024

A typo, thanks for point out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

3 participants