// a scheduler isn't actually referenced, but might be
// (e.g. for collection stats)
sclass PMapCollector /*extends Probabilistic*/ {
new Map map;
new L> onNewEntry;
new L> onChangedEntry;
*() {}
*(Map *map) {}
void put(A key, B value) {
bool isNew = !map.containsKey(key);
B oldValue = null;
bool isChanged = !isNew && !eq(oldValue = map.get(key), value);
if (isNew || isChanged)
map.put(key, value);
if (isNew)
pcallFAll(onNewEntry, key, value);
else
pcallFAll(onChangedEntry, key, oldValue, value);
}
}