Clover icon

Coverage Report

  1. Project Clover database Wed Nov 13 2024 18:27:33 GMT
  2. Package jalview.datamodel

File VisibleRowsIterator.java

 

Coverage histogram

../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

8
18
4
1
99
53
11
0.61
4.5
4
2.75

Classes

Class Line # Actions
VisibleRowsIterator 32 18 11
1.0100%
 

Contributing tests

This file is covered by 19 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.datamodel;
22   
23    import java.util.Iterator;
24    import java.util.NoSuchElementException;
25   
26    /**
27    * An iterator which iterates over all visible rows in an alignment
28    *
29    * @author kmourao
30    *
31    */
 
32    public class VisibleRowsIterator implements Iterator<Integer>
33    {
34    private int last;
35   
36    private int current;
37   
38    private int next;
39   
40    private HiddenSequences hidden;
41   
42    private AlignmentI al;
43   
44    /**
45    * Create an iterator for all visible rows in the alignment
46    *
47    * @param firstrow
48    * absolute row index to start from
49    * @param lastrow
50    * absolute row index to end at
51    * @param alignment
52    * alignment to work with
53    */
 
54  274 toggle public VisibleRowsIterator(int firstrow, int lastrow,
55    AlignmentI alignment)
56    {
57  274 al = alignment;
58  274 current = firstrow;
59  274 last = lastrow;
60  274 hidden = al.getHiddenSequences();
61  859 while (last > current && hidden.isHidden(last))
62    {
63  585 last--;
64    }
65  274 current = firstrow;
66  280 while (current < last && hidden.isHidden(current))
67    {
68  6 current++;
69    }
70  274 next = current;
71    }
72   
 
73  2446 toggle @Override
74    public boolean hasNext()
75    {
76  2446 return next <= last;
77    }
78   
 
79  2292 toggle @Override
80    public Integer next()
81    {
82  2292 if (next > last)
83    {
84  4 throw new NoSuchElementException();
85    }
86  2288 current = next;
87  2288 do
88    {
89  2425 next++;
90  2425 } while (next <= last && hidden.isHidden(next));
91  2288 return current;
92    }
93   
 
94  1 toggle @Override
95    public void remove()
96    {
97  1 throw new UnsupportedOperationException();
98    }
99    }