--
guava-...@googlegroups.com.
http://groups.google.com/group/guava-discuss?hl=en
unsubscribe: guava-discus...@googlegroups.com
This list is for discussion; for help, post to Stack Overflow instead:
http://stackoverflow.com/questions/ask
Use the tag "guava".
To unsubscribe from this group, send email to guava-discuss+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
I am enlighted. Just took some thought.
But unfortunately guava still lacks some basic functionality to make
working with immutable collections user friendly. (Last time i
checked, that is. But that may have been a while ago)
Johan Van den Neste
But unfortunately guava still lacks some basic functionality to make
working with immutable collections user friendly. (Last time i
checked, that is. But that may have been a while ago)
Making new immutable maps from existing maps with some mappings
removed or added. (unless it was added, and I missed it, for which I
apologize).
http://code.google.com/p/guava-libraries/issues/detail?id=306&can=1&q=jvdneste
Also, the performance of these operations is bad. There are better
ways of implementing immutable map and lists. "Better" is the wrong
word: they have different performance characteristics making adding
and removing mappings cheaper but lookups slightly more expensive. (as
in clojure, and, I suspect, scala 2.8, but i haven't found any details
on that yet)
But I repeat myself. It's just that I find working with immutable
structures very productive. There's a lot less to worry about. (except
performance).
I must admit I haven't picked up on guava yet, but I will do so once a
binary has been released and the discussed api stability annotations
are in place.
--
Johan Van den Neste
--
guava-...@googlegroups.com.
http://groups.google.com/group/guava-discuss?hl=en
unsubscribe: guava-discus...@googlegroups.com
This list is for discussion; for help, post to Stack Overflow instead:
http://stackoverflow.com/questions/ask
Use the tag "guava".
To unsubscribe, reply using "remove me" as the subject.
--
Johan Van den Neste
Making new immutable maps from existing maps with some mappings
removed or added. (unless it was added, and I missed it, for which I
apologize).
s/Iterable/map/, but yes, this is how you have to do it. It's not hard to imagine a more convenient API for doing this, though.
public static <K,V> ImmutableMap<K,V>
with(final ImmutableMap<K,V> map, final K key, final V value) {
return ImmutableMap.<K,V>builder().putAll(Maps.filterKeys(map,
Predicates.not(Predicates.equalTo(key)))).put(key, value).build();
}
is what I have.
But it's hardly efficient.
True. I'm not criticizing the existing api. I'm just saying that the
with/without methods can be implemented much more efficiently within
guava, and that it shouldn't get the 'convenience' label as a result.
(I think I called them convenience earlier. That was a mistake)