// collects into l
static Collector limitedListCollector(final Collection l, final int max) {
ret new Collector() {
bool full() {
ret l(l) >= max;
}
bool add(A a) {
if (full()) false;
l.add(a);
ret full();
}
bool contains(A a) {
ret l.contains(a);
}
};
}