| 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.Iterator; |
| 24 |
|
import java.util.NoSuchElementException; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@author |
| 32 |
|
|
| 33 |
|
|
| |
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 10 |
Complexity Density: 0.53 |
|
| 34 |
|
public class RangeElementsIterator implements Iterator<Integer> |
| 35 |
|
{ |
| 36 |
|
private int last; |
| 37 |
|
|
| 38 |
|
private int current; |
| 39 |
|
|
| 40 |
|
private int next; |
| 41 |
|
|
| 42 |
|
private Iterator<int[]> rangeIterator; |
| 43 |
|
|
| 44 |
|
private int[] nextRange = null; |
| 45 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 46 |
0 |
RangeElementsIterator(Iterator<int[]> it)... |
| 47 |
|
{ |
| 48 |
0 |
rangeIterator = it; |
| 49 |
0 |
if (rangeIterator.hasNext()) |
| 50 |
|
{ |
| 51 |
0 |
nextRange = rangeIterator.next(); |
| 52 |
0 |
next = nextRange[0]; |
| 53 |
0 |
last = nextRange[1]; |
| 54 |
|
} |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
0 |
@Override... |
| 58 |
|
public boolean hasNext() |
| 59 |
|
{ |
| 60 |
0 |
return rangeIterator.hasNext() || next <= last; |
| 61 |
|
} |
| 62 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 63 |
0 |
@Override... |
| 64 |
|
public Integer next() |
| 65 |
|
{ |
| 66 |
0 |
if (!hasNext()) |
| 67 |
|
{ |
| 68 |
0 |
throw new NoSuchElementException(); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
0 |
current = next; |
| 72 |
|
|
| 73 |
|
|
| 74 |
0 |
next++; |
| 75 |
|
|
| 76 |
|
|
| 77 |
0 |
checkNextRange(); |
| 78 |
0 |
return current; |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 85 |
0 |
private void checkNextRange()... |
| 86 |
|
{ |
| 87 |
0 |
if (nextRange != null && next > nextRange[1]) |
| 88 |
|
{ |
| 89 |
0 |
if (rangeIterator.hasNext()) |
| 90 |
|
{ |
| 91 |
0 |
nextRange = rangeIterator.next(); |
| 92 |
0 |
next = nextRange[0]; |
| 93 |
0 |
last = nextRange[1]; |
| 94 |
|
} |
| 95 |
|
else |
| 96 |
|
{ |
| 97 |
0 |
nextRange = null; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
} |
| 101 |
|
} |
| 102 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 103 |
0 |
@Override... |
| 104 |
|
public void remove() |
| 105 |
|
{ |
| 106 |
0 |
throw new UnsupportedOperationException(); |
| 107 |
|
} |
| 108 |
|
} |