Closed GoogleCodeExporter closed 9 years ago
Do you propose that the computed values are cached/stored upon first
computation? If not, passing in a non-pure function would allow one to create a
"mutable ImmutableMap".
(But even then, lazy computation and storage of values i.c.w. a non-pure
function could make the ImmutableMap's final content dependent on the order in
which keys are first accessed...)
Perhaps I misunderstood the request, though. For example, in your scenario, if
the object to which you pass the ImmutableMap view will access all key/value
pairs anyway, then you might as well copy eagerly. (Unless of course it's
better that this work is amortized or performed in another thread.)
Side node: from an architectural point of view, shouldn't consumers generally
ask for a Map and produce the ImmutableMap themselves, using #copyOf()?
Performance-wise that's unlikely to make a difference, while providing more
flexibility to API users. Anyway, I digress.
Original comment by stephan...@gmail.com
on 18 May 2013 at 7:40
I had made the assumption that Function was one-to-one and not a multivalued
function... I think you are right, my proposal is not really worthy unless you
can somehow guarantee that you have an ImmutableFunction (whatever that means).
Also, regarding to your last point, I was starting to think the along the same
lines... The API should be using the Map *interface* not ImmutableMap so my use
case is kinda out the window.
I'm happy to see this marked as WontFix :)
Original comment by corin.la...@gmail.com
on 18 May 2013 at 12:48
Original comment by cpov...@google.com
on 18 May 2013 at 1:27
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<issue id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:12
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
corin.la...@gmail.com
on 18 May 2013 at 5:46