// threshold must be at least 2
// not synchronized
// untested
srecord BigLittleMapPolicy(Class extends Map> smallClass, Class extends Map> bigClass, int threshold) implements IMapImplementationPolicy {
bool nullOnEmpty = false;
public Map makeSingletonMap(A key, B value) {
ret put(null, key, value);
}
public Map put(Map map, A key, B value) {
if (map == null) map = newInstance(smallClass);
if (l(map) == threshold-1 && !map.containsKey(key))
map = putAll(newInstance(bigClass), map);
map.put(key, value);
ret map;
}
public Map remove(Map map, O key) {
if (map == null || !map.containsKey(key)) ret map;
map.remove(key);
int n = l(map);
if (n == threshold-1)
map = putAll(newInstance(smallClass), map);
ret nullOnEmpty && n == 0 ? null : map;
}
}