1
2
3
4
5
6
7
8
9public
10class Unique extends Sequence {
11 private
12 long last;
13
14 private
15 Sequence s;
16
17 public
18 Unique(Sequence s) {
19 this.s = s;
20 this.last = s.next();
21 }
22
23 public
24 long next() {
25 long res = last;
26
27 while ( (last = s.next()) == res );
28
29 return res;
30 }
31}
32
33
34