Logik und Logische Programmierung Einführung
Logik und Logische Programmierung Einführung
Logik und Logische Programmierung Einführung
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Permutator.javapackage de.jastram.truthtable;import java.util.Iterator;/** * AnIterator that provides permutations for n boolean values, where n isthe * argument to the constructor. The results are provided as booleanarrays. */public class Permutator implements Iterator {!private int length; !private int counter = 0;!publicPermutator(intnumFields){ !!if(numFields>31)! ! !throw new IndexOutOfBo<strong>und</strong>sException("Too many variables!"); ! !this.length =numFields; !} !public boolean hasNext() { !!return counter < (Math.pow(2, length)); !}!public boolean[] next() { ! !boolean[]bits = new boolean[length]; ! !for (int i = 0; i >i; ! ! !bits[i] = (shift % 2 == 1);! !} ! !counter++; !!return bits; !} !public void remove() {! !throw new UnsupportedOperationException();!}}!