Hi Sean,
bad news ;-) ...
Am 22.03.2012 08:28, schrieb Sean Chou:
Hi Ulf,
I'm glad you agreed my suggestion.
To all:
Can this patch be committed as it has been reviewed by David Holmes and Mike Duigou, and Ulf
also says agreed ?
I agree with your implementation of AbstractCollection, but NOT with the test.
For correct testing I suggest to use:
/**
*
* @author Ulf Zibis
*/
public class TestCollection<E> extends AbstractCollection<E> {
private E[] elements;
private int[] sizes;
private int nextSize;
public TestCollection(E[] elements) {
this.elements = elements;
setConcurrentSizeCourse(null);
}
void setConcurrentSizeCourse(int... sizes) {
this.sizes = sizes == null ? new int[]{elements.length} : sizes;
nextSize = 0;
}
@Override
public int size() {
return sizes[nextSize == sizes.length-1 ? nextSize : nextSize++];
}
@Override
public Iterator<E> iterator() {
return new Iterator<>() {
int pos = 0;
public boolean hasNext() {
return pos < sizes[nextSize];
}
public E next() {
return elements[pos++];
}
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
}
-Ulf