Class EfMsSeq
java.lang.Object
io.github.olyutorskii.aletojio.emergence.EfMsSeq
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
hashCode()
int
lastIdxSuffix
(int suffixIdx) Return last index of suffix pattern appeared in bit sequence.int
length()
Return length of bit sequence.int
nextBool()
Determin next random bit from past bits.toString()
-
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
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
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
Determin next random bit from past bits.- Returns:
- next random bit. (0 or 1)
- Throws:
NullPointerException
- argument is null
-
hashCode
public int hashCode() -
equals
-
toString
Output 0/1 sequence in historical order.
-