![]() |
Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
|
Binary reflected Gray code generator. More...
#include <BinaryGrayCode.h>
Public Member Functions | |
~CBinaryGrayCode () | |
Destructor. More... | |
virtual void | Initialize (const UINT) |
Get first code word. More... | |
virtual UINT | Next () |
Get next code word. More... | |
Public Attributes | |
UINT | m_nZeros = 0 |
Number of zeros in the code word. More... | |
UINT | m_nSize = 0 |
Size of the code word. More... | |
UINT * | m_nGrayCodeWord = nullptr |
Current code word. More... | |
UINT * | m_nGrayCodeStack = nullptr |
Stack to remove recursion. More... | |
A binary Gray code generates all strings of a fixed number of bits in such a way that each string differs from the previous one in exactly one bit. For example, the following is a binary reflected Gray code on 4 bits with each bit string followed by the index of the changed bit (from left to right starting at zero).
This class implements a nonrecursive version of the binary reflected Gray code generation algorithm from the following paper:
Bitner, Ehrlich, and Reingold, "Efficient generation of the Binary Reflected Gray Code and its applications", Communications of the ACM, Vol. 19, No. 9, pp 517-521, 1976.
Definition at line 66 of file BinaryGrayCode.h.
CBinaryGrayCode::~CBinaryGrayCode | ( | ) |
Delete the memory in the Gray code word and stack.
Definition at line 30 of file BinaryGrayCode.cpp.
|
virtual |
Initialize and set the Gray code generator to the first word in Gray code order, which is the all-zero word.
n | Number of bits in the Gray code word. |
Reimplemented in CTernaryGrayCode.
Definition at line 39 of file BinaryGrayCode.cpp.
|
virtual |
Get the next binary word in binary reflected Gray code order, which will differ from the previous one in exactly one bit.
Reimplemented in CTernaryGrayCode.
Definition at line 65 of file BinaryGrayCode.cpp.
UINT* CBinaryGrayCode::m_nGrayCodeStack = nullptr |
Definition at line 71 of file BinaryGrayCode.h.
UINT* CBinaryGrayCode::m_nGrayCodeWord = nullptr |
Definition at line 70 of file BinaryGrayCode.h.
UINT CBinaryGrayCode::m_nSize = 0 |
Definition at line 69 of file BinaryGrayCode.h.
UINT CBinaryGrayCode::m_nZeros = 0 |
Definition at line 68 of file BinaryGrayCode.h.