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

Add reverse method to Iterable #26928

Closed
dragostis opened this issue Jul 20, 2016 · 1 comment
Closed

Add reverse method to Iterable #26928

dragostis opened this issue Jul 20, 2016 · 1 comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@dragostis
Copy link

Iterable<E> has no reverse method. This method would come in handy especially when wanting to do fold right on an interable:

// current
iterable.toList().reversed.fold(...)

// proposed
iterable.reverse().fold(...)

Where reverse() would have a similar effect to toList().reversed.

@mit-mit mit-mit added the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Jul 21, 2016
@lrhn
Copy link
Member

lrhn commented Jul 22, 2016

The problem with reverse is that there are no performance guarantees. Most implementations would have to just do Iterable<T> get reversed => new IterableWrapper<T>(this.toList().reversed);.

That makes .toList().reversed and .reversed() equivalent, and you don't need two ways to do the same thing.

We are not planning on adding new members to Iterable at this point unless it's extremely important and/or useful.

(There are a few collections that can actually reverse their members in constant time: LinkedHash based structures, tree-based (ordered) structures, queues and List, but there is no easy way to see if you have one of those).

@lrhn lrhn closed this as completed Jul 22, 2016
@lrhn lrhn added type-enhancement A request for a change that isn't a bug closed-not-planned Closed as we don't intend to take action on the reported issue labels Jul 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants