Closed GoogleCodeExporter closed 9 years ago
public static <K,V> ImmutableMap<K,V> with(final ImmutableMap<K,V> map,
final K key, final V value) {
final Map<K, V> filtered = Maps.filterKeys(map,
Predicates.not(Preds.is(key)));
return ImmutableMap.<K,V>builder()
.putAll(filtered)
.put(key, value)
.build();
}
public static <K,V> ImmutableMap<K,V> without(final ImmutableMap<K,V> map,
final K key) {
final Map<K, V> filtered = Maps.filterKeys(map,
Predicates.not(Predicates.in(Collections.singleton(key))));
return ImmutableMap.copyOf(filtered);
}
public static <K,V> ImmutableMap<K,V> without(final ImmutableMap<K,V> map,
final Set<K> keys) {
final Map<K, V> filtered = Maps.filterKeys(map,
Predicates.not(Predicates.in(keys)));
return ImmutableMap.copyOf(filtered);
}
Original comment by jvdne...@gmail.com
on 16 Dec 2009 at 1:26
We don't wish to attempt to turn our collections into full-blown "persistent
data
structures" aka "pure functional data structures". There are lots of other
languages
and libraries that have this if it's what you want.
Original comment by kevinb@google.com
on 23 Apr 2010 at 8:31
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:16
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:10
Original issue reported on code.google.com by
jvdne...@gmail.com
on 9 Dec 2009 at 2:29