1
2
3
4
5
6
7
8public
9class Merge1 extends Sequence {
10 private
11 long hd2;
12
13 private
14 Sequence s1, s2;
15
16 public
17 Merge1(Sequence s1, Sequence s2) {
18
19 this.s1 = s1;
20 this.s2 = s2;
21
22 hd2 = s2.next();
23 }
24
25 public
26 long next() {
27 long res;
28
29 res = s1.next();
30 if ( res > hd2 ) {
31
32
33 Sequence s3;
34 s3 = s1;
35 s1 = s2;
36 s2 = s3;
37
38 long hd1;
39 hd1 = res;
40 res = hd2;
41 hd2 = hd1;
42 }
43
44 return res;
45 }
46}
47
48
49