blob: 302619c5b9a66a9a9bb5af18ea746b91a3c493fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package com.vaadin.tests.util;
import java.util.AbstractCollection;
import java.util.Iterator;
public class RangeCollection extends AbstractCollection<Integer> {
public static class RangeIterator implements Iterator<Integer> {
private int value;
private int max;
public RangeIterator(int max) {
this.max = max;
value = 0;
}
@Override
public boolean hasNext() {
return (value < max - 1);
}
@Override
public Integer next() {
return value++;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
}
private int size = 0;
public RangeCollection(int size) {
this.size = size;
}
@Override
public Iterator<Integer> iterator() {
return new RangeIterator(size - 1);
}
@Override
public int size() {
return size;
}
}
|