Whither extension methods?
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.
2009/12/15 Joshua Bloch <jjb at google.com>
> Doug Lea sent this a couple of days ago, and I think it deserves our
> 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 --
> > can only get an iterator, which is inherently sequential. Now, if we
> > could get at the representations, then we could actually do splits for
> > java.util maps (at least for the most common ones -- HashMaps, TreeMaps).
> > the only way I know for these to be bolted on is to introduce new
> > that each of the these existing classes could be changed to implement. Or
> > I missing something?
> > You might want to read Guy Steele's nice talk on related issues at
> > -Doug
More information about the lambda-dev