Class BitSwitcher

java.lang.Object
io.github.olyutorskii.aletojio.shrink.BitSwitcher
All Implemented Interfaces:
RndInt32

public class BitSwitcher extends Object implements RndInt32
Switch output bits from 2 input streams.

Another stream is required to provide the switching. If switching-bit is 0, output 1st input stream bit. If switching-bit is 1, output 2nd input stream bit.

Random number output throughput decreases 1/3.

Example

  • input stream 1st 01010101
  • input stream 2nd 11001100
  • switch stream 00001111
will be output 01011100
  • Constructor Details

  • Method Details

    • nextInt32

      public int nextInt32()
      Return next random number as 32bit int with random sign-bit.
      Specified by:
      nextInt32 in interface RndInt32
      Returns:
      random number