Re: Immutable Datastructures with good Sharing
Jan Burse schrieb:
I guess the putAll() results in cloning, therefore
no good sharing, therefore not a solution to the
problem at hand.
But I might be wrong.
Yep it is of no use.
First we have behind newArrayList the following:
public static <E> ArrayList<E> newArrayList() {
return new ArrayList<E>();
}
http://code.google.com/p/google-collections/source/browse/trunk/src/com/google/common/collect/Lists.java
Then we have behind put and putAll():
public static class Builder<K, V> {
final List<Entry<K, V>> entries = Lists.newArrayList();
public Builder<K, V> put(K key, V value) {
entries.add(entryOf(key, value));
return this;
}
public Builder<K, V> putAll(Map<? extends K, ? extends V> map) {
for (Entry<? extends K, ? extends V> entry : map.entrySet()) {
put(entry.getKey(), entry.getValue());
}
return this;
}
http://www.docjar.com/html/api/com/google/inject/internal/ImmutableMap.java.html
So the whole thing, in version 1.0, doesn't make
much sense, except that it has the label
Google on it.
Bye