diff --git a/src/main/java/org/warp/commonutils/random/LFSR.java b/src/main/java/org/warp/commonutils/random/LFSR.java index 542b108..a3fba5b 100644 --- a/src/main/java/org/warp/commonutils/random/LFSR.java +++ b/src/main/java/org/warp/commonutils/random/LFSR.java @@ -3,6 +3,7 @@ package org.warp.commonutils.random; import java.math.BigInteger; import java.util.Iterator; import java.util.Random; +import org.jetbrains.annotations.NotNull; /** * Linear feedback shift register @@ -58,12 +59,13 @@ public class LFSR implements Iterable { this.taps = primitivePoly.shiftRight(1); } + @NotNull @Override - public Iterator iterator() { + public LFSRIterator iterator() { return new LFSRIterator(start); } - private class LFSRIterator implements Iterator { + public class LFSRIterator implements Iterator { // The last one we returned. private BigInteger last = null; @@ -110,6 +112,12 @@ public class LFSR implements Iterable { return last; } + public BigInteger next(BigInteger last) { + this.last = last; + next = null; + return next(); + } + @Override public void remove() { throw new UnsupportedOperationException("Not supported.");