java.lang.Object
io.github.olyutorskii.aletojio.emergence.EfMsSeq

public class EfMsSeq extends Object
Ehrenfeucht-Mycielski random bits sequence.

Continue to generate random bits sequences acyclic and emergently until the memory capacity and indexing mechanism reach their limits.

This is Automatic sequence. This means infinite sequence from finite automaton.

It is only possible to add bit to the end of sequence.

TODO: use suffix tree.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    append(int iVal)
    Append new bit to tail of bit sequence.
    void
    append(int... iVals)
    Append new bits to tail of bit sequence.
    boolean
    int
    get(int idx)
    Get bit from bit sequence with index.
    int
    int
    lastIdxSuffix(int suffixIdx)
    Return last index of suffix pattern appeared in bit sequence.
    int
    Return length of bit sequence.
    int
    Determin next random bit from past bits.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • EfMsSeq

      public EfMsSeq()
      Constructor.

      Bit sequence is empty.

  • Method Details

    • length

      public int length()
      Return length of bit sequence.
      Returns:
      length of bit sequence
    • append

      public void append(int iVal)
      Append new bit to tail of bit sequence.
      Parameters:
      iVal - bit. 0 means 0b0, not 0 means 0b1.
    • append

      public void append(int... iVals)
      Append new bits to tail of bit sequence.
      Parameters:
      iVals - bits. 0 means 0b0, not 0 means 0b1.
    • get

      public int get(int idx) throws IndexOutOfBoundsException
      Get bit from bit sequence with index.

      Index starts with 0 (oldest bit). Index ends with bit sequence length - 1 (recently added bit).

      Parameters:
      idx - bit position. 0 means oldest bit.
      Returns:
      bit. 0 means 0b0. 1 means 0b1.
      Throws:
      IndexOutOfBoundsException - illegal index
    • lastIdxSuffix

      public int lastIdxSuffix(int suffixIdx) throws IndexOutOfBoundsException
      Return last index of suffix pattern appeared in bit sequence.

      Suffix never unmatch it self.

      Suffix of "01010010101" with index 8 is "101".

      "101" pattern appear 3-times in "01010010101". 3rd one is ignored because last one is suffix it self.

      Therefore, last index of "01010010101" with suffix index 8 is position 6

      Parameters:
      suffixIdx - index of suffix starting
      Returns:
      last index of suffix pattern appeared in bit sequence. Negative if unmatched.
      Throws:
      IndexOutOfBoundsException - invalid index
    • nextBool

      public int nextBool() throws NullPointerException
      Determin next random bit from past bits.
      Returns:
      next random bit. (0 or 1)
      Throws:
      NullPointerException - argument is null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      Parameters:
      obj -
      Returns:
    • toString

      public String toString()

      Output 0/1 sequence in historical order.

      Overrides:
      toString in class Object
      Returns:
      bit sequence text. "nil" if empty.