public class StringEncoderTwoWords
extends java.lang.Object
The triangulation is encoded with two binary strings of length 2n.
In this implementation the two strings are encoded separately, as two BitSets. These two strings can be written/read in a sequential manner independently.
Modifier and Type | Field and Description |
---|---|
BitSet32 |
blackWord
Bit string encoding the black word
|
int |
n
Number of vertices of the planar triangulation
|
BitSet32 |
redWord
Bit string encoding the red word
|
Constructor and Description |
---|
StringEncoderTwoWords(BitSet32 red,
BitSet32 black,
int n)
Initialize the two bit sets
|
StringEncoderTwoWords(int n)
Initialize the two bit sets
|
Modifier and Type | Method and Description |
---|---|
void |
addBlackBlock(int degree)
Add a new block of (d+1) symbols to the black word: a sequence of size 'd' of one bits, followed by '0', as below:
|
void |
addBlackChar(int bit)
Add a new bit to the black String
|
void |
addRedChar(int bit)
Add a new bit to the red String
|
boolean |
check()
Check the correctness of the encoding.
|
java.lang.String |
getBlackWord()
Return the two red word (encoding the red tree), as a String
|
int |
getMaxDepthRed()
Count the max depth of the balanced red word
|
java.lang.String |
getRedWord()
Return the two red word (encoding the red tree), as a String
|
int |
readNextBlackBlock()
Return the black block size: in-degree of black edges.
|
int |
readNextRedChar()
Return the next bit in the red string
|
void |
resetGlobalCounters()
Re-initialize the global counters: for re-starting the reading or writing phases
|
java.lang.String |
toString()
Return the two red and black strings
|
public final int n
public BitSet32 redWord
public BitSet32 blackWord
public StringEncoderTwoWords(int n)
n
- the number of vertices of the triangulationpublic void resetGlobalCounters()
public void addRedChar(int bit)
bit
- an integer value: '0' or '1'public void addBlackChar(int bit)
bit
- an integer value: '0' or '1'public void addBlackBlock(int degree)
'1...10'
degree
- the number of '1' bits in the stringpublic int readNextRedChar()
(for the decoding phase)
public int readNextBlackBlock()
(for the decoding phase)
Remark: a block consists of a sequence of '1' bits (possibly empty) followed by a '0' bit
example of a block: 0, 10, 1111110
return
- the number of '1' bits in the block (in the black word)public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getRedWord()
public java.lang.String getBlackWord()
public int getMaxDepthRed()
public boolean check()
-) the red word must be balanced
-) the black word must contain exactly (n-1) '1' bits