00001 package edu.tum.cs.srl.bayesnets.bln.py; 00002 00003 import java.util.Iterator; 00004 00005 import org.python.core.PyObject.ConversionException; 00006 00007 00008 public class GroundFormulaIteration implements Iterator<GroundFormula>, Iterable<GroundFormula> { 00009 00010 protected BayesianLogicNetworkPy bln; 00011 protected int i, count; 00012 00013 public GroundFormulaIteration(BayesianLogicNetworkPy bln) throws ConversionException { 00014 this.bln = bln; 00015 i = 0; 00016 count = bln.jython.evalInt("len(mln.gndFormulas)"); 00017 } 00018 00019 public boolean hasNext() { 00020 return i < count; 00021 } 00022 00023 public GroundFormula next() { 00024 try { 00025 return new GroundFormula(bln.jython, i++); 00026 } 00027 catch (ConversionException e) { 00028 throw new RuntimeException(e.getMessage()); 00029 } 00030 } 00031 00032 public void remove() { 00033 throw new RuntimeException("Remove is not supported by this iterator."); 00034 } 00035 00036 public Iterator<GroundFormula> iterator() { 00037 return this; 00038 } 00039 00044 public int getCount() { 00045 return count; 00046 } 00047 }