/** * putAll with a chance to handle collisions. Function3<Key, Object_here, Object_there, * Object_or_null_as_merged> */ public Dict putAll(Dict d, Curry.Function3<Object, Object, Object, Object> collision) { for (Map.Entry<Prop, Object> e : d.dictionary.entrySet()) { if (!dictionary.containsKey(e.getKey())) put(e.getKey(), e.getValue()); else { Object r = collision.apply(e.getKey(), dictionary.get(e.getKey()), e.getValue()); if (r != null) put(e.getKey(), r instanceof Mutable ? ((Mutable) r).duplicate() : r); } } return this; }
/** returns a dict of the things displaced by putting this */ public Dict putAll(Dict d) { Dict r = new Dict(); for (Map.Entry<Prop, Object> e : d.dictionary.entrySet()) { Object was = get(e.getKey()); put(e.getKey(), e.getValue()); if (was != null) r.put(e.getKey(), was instanceof Mutable ? ((Mutable) was).duplicate() : was); } return r; }
/** putAll, filtered */ public Dict putAll(Dict d, Function<Prop, Boolean> filter) { for (Map.Entry<Prop, Object> e : d.dictionary.entrySet()) { if (filter.apply(e.getKey())) { put( e.getKey(), e.getValue() instanceof Mutable ? ((Mutable) e.getValue()).duplicate() : e.getValue()); } } return this; }
public void multiply(Prop<Float> k, float missingValue, float by) { put(k, getFloat(k, missingValue) * by); }