Coverage Report - net.sourceforge.combean.samples.simplegraphs.NumberNodeIterator
 
Classes in this File Line Coverage Branch Coverage Complexity
NumberNodeIterator
100%
7/7
100%
2/2
1
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 11.01.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.samples.simplegraphs;
 23  
 
 24  
 import net.sourceforge.combean.graph.NumberNode;
 25  
 import net.sourceforge.combean.interfaces.graph.Node;
 26  
 import net.sourceforge.combean.interfaces.graph.NodeIterator;
 27  
 
 28  
 /**
 29  
  * An iterator through a sequence of NumberNodes with consecutive numbers.
 30  
  * 
 31  
  * @author schickin
 32  
  *
 33  
  */
 34  
 public class NumberNodeIterator implements NodeIterator {
 35  
         
 36  
         int from;
 37  
         int to;
 38  
         int curr;
 39  
 
 40  
         /**
 41  
          * Generate an iterator through a consecutive range of numbered nodes
 42  
          * 
 43  
          * @param from
 44  
          * @param to
 45  
          */
 46  
         public NumberNodeIterator(int from, int to) {
 47  57
                 super();
 48  57
                 this.from = from;
 49  57
                 this.to = to;
 50  57
                 this.curr = from-1;
 51  57
         }
 52  
 
 53  
         /**
 54  
          * @see net.sourceforge.combean.interfaces.graph.NodeIterator#hasNext()
 55  
          */
 56  
         public boolean hasNext() {
 57  366
                 return this.curr < this.to;
 58  
         }
 59  
 
 60  
         /**
 61  
          * @see net.sourceforge.combean.interfaces.graph.NodeIterator#next()
 62  
          */
 63  
         public Node next() {
 64  306
                 return new NumberNode(++this.curr);
 65  
         }
 66  
 
 67  
 }