Whither extension methods?
Osvaldo Doederlein
opinali at gmail.com
Tue Dec 15 09:13:35 PST 2009
This remembers me that collections like TreeMap and TreeSet could have a
method that returns the root key or entry. So we could then use many
existing methods like headMap(), higherKey() etc., for [recursive]
divide-and-conquer algorithms, with or without concurrency or lambdas.
A+
Osvaldo
2009/12/15 Joshua Bloch <jjb at google.com>
> Doug Lea sent this a couple of days ago, and I think it deserves our
> consideration:
>
> I confess to being a little confused about the rationale for extension
> > methods.
>
>
> > Suppose we have a Map, and want to some sort of apply-to-each-value
> > operation. The only reasonable way to do this in parallel is to somehow
> > splitthe work. But Map has no public methods allowing you to do this --
> you
> > can only get an iterator, which is inherently sequential. Now, if we
> > could get at the representations, then we could actually do splits for
> most
> > java.util maps (at least for the most common ones -- HashMaps, TreeMaps).
> So
> > the only way I know for these to be bolted on is to introduce new
> interfaces
> > that each of the these existing classes could be changed to implement. Or
> am
> > I missing something?
>
>
> > You might want to read Guy Steele's nice talk on related issues at
> >
> http://groups.csail.mit.edu/mac/users/gjs/6.945/readings/MITApril2009Steele.pdf
>
>
> > -Doug
>
>
More information about the lambda-dev
mailing list