1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.datamodel; |
22 |
|
|
23 |
|
import java.util.ArrayList; |
24 |
|
import java.util.Iterator; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
|
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 12 |
Complexity Density: 0.52 |
|
31 |
|
public class RangeIterator implements Iterator<int[]> |
32 |
|
{ |
33 |
|
|
34 |
|
private int currentPosition = 0; |
35 |
|
|
36 |
|
|
37 |
|
private int[] currentRange; |
38 |
|
|
39 |
|
|
40 |
|
private List<int[]> localRanges; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@param |
46 |
|
|
47 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
48 |
0 |
RangeIterator(List<int[]> rangeList)... |
49 |
|
{ |
50 |
0 |
if (!rangeList.isEmpty()) |
51 |
|
{ |
52 |
0 |
int last = rangeList.get(rangeList.size() - 1)[1]; |
53 |
0 |
init(0, last, rangeList); |
54 |
|
} |
55 |
|
else |
56 |
|
{ |
57 |
0 |
init(0, 0, rangeList); |
58 |
|
} |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
@param |
65 |
|
|
66 |
|
@param |
67 |
|
|
68 |
|
@param |
69 |
|
|
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0 |
RangeIterator(int lowerBound, int upperBound, List<int[]> rangeList)... |
72 |
|
{ |
73 |
0 |
init(lowerBound, upperBound, rangeList); |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
@param |
80 |
|
|
81 |
|
@param |
82 |
|
|
83 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.46 |
|
84 |
0 |
private void init(int lowerBound, int upperBound, List<int[]> rangeList)... |
85 |
|
{ |
86 |
0 |
int start = lowerBound; |
87 |
0 |
int end = upperBound; |
88 |
|
|
89 |
0 |
if (rangeList != null) |
90 |
|
{ |
91 |
0 |
localRanges = new ArrayList<>(); |
92 |
|
|
93 |
|
|
94 |
0 |
int i = 0; |
95 |
0 |
while ((i < rangeList.size()) && (rangeList.get(i)[1] < start)) |
96 |
|
{ |
97 |
0 |
i++; |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
0 |
while (i < rangeList.size() && (rangeList.get(i)[0] <= end)) |
103 |
|
{ |
104 |
0 |
int[] rh = rangeList.get(i); |
105 |
0 |
int[] cp = new int[2]; |
106 |
0 |
System.arraycopy(rh, 0, cp, 0, rh.length); |
107 |
0 |
localRanges.add(cp); |
108 |
0 |
i++; |
109 |
|
} |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0 |
@Override... |
114 |
|
public boolean hasNext() |
115 |
|
{ |
116 |
0 |
return (localRanges != null) && (currentPosition < localRanges.size()); |
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
119 |
0 |
@Override... |
120 |
|
public int[] next() |
121 |
|
{ |
122 |
0 |
currentRange = localRanges.get(currentPosition); |
123 |
0 |
currentPosition++; |
124 |
0 |
return currentRange; |
125 |
|
} |
126 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
0 |
@Override... |
128 |
|
public void remove() |
129 |
|
{ |
130 |
0 |
localRanges.remove(--currentPosition); |
131 |
|
} |
132 |
|
} |