![]() |
Sorting Network Search
Backtracking for Small Sorting Networks
|
Binary reflected Gray code generator. More...
#include <BinaryGrayCode.h>
Public Member Functions | |
virtual void | Initialize () |
Get first code word. More... | |
virtual size_t | Next () |
Get next code word. More... | |
void | Print () |
Debug print. More... | |
Protected Attributes | |
size_t | m_nBit [MAXINPUTS+3] = {0} |
Current code word. More... | |
size_t | m_nStack [MAXINPUTS+3] = {0} |
Stack to remove recursion. More... | |
Additional Inherited Members | |
![]() | |
static void | SetWidth (const size_t) |
Set width. More... | |
static void | SetDepth (const size_t) |
Set depth. More... | |
![]() | |
static size_t | m_nWidth = 9 |
Comparator network width. More... | |
static size_t | m_nDepth = 6 |
Comparator network depth. 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.
|
virtual |
Reset Gray code generator to the first word in Gray code order, which is the all-zero word.
Reimplemented in CTernaryGrayCode.
Definition at line 33 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 45 of file BinaryGrayCode.cpp.
void CBinaryGrayCode::Print | ( | ) |
Print to the console a sequence of Gray code changes, that is, the index of the bit that flips to get the next binary string.
Definition at line 59 of file BinaryGrayCode.cpp.
|
protected |
Definition at line 68 of file BinaryGrayCode.h.
|
protected |
Definition at line 69 of file BinaryGrayCode.h.