Sorting Network Search
Backtracking for Small Sorting Networks
Public Member Functions | Protected Attributes | List of all members
CComparatorNetwork Class Reference

Comparator network. More...

#include <ComparatorNetwork.h>

Inheritance diagram for CComparatorNetwork:
CSettings CSortingNetwork C1NF CSearchable C2NF CAutocomplete CNearsort CNearsort2

Public Member Functions

 CComparatorNetwork ()
 Constructor. More...
 
virtual ~CComparatorNetwork ()
 Destructor. More...
 
void Save (const std::string &)
 Save to file. More...
 

Protected Attributes

size_t m_nComparator [MAXDEPTH][MAXINPUTS] = {0}
 Comparator array. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CSettings
static void SetWidth (const size_t)
 Set width. More...
 
static void SetDepth (const size_t)
 Set depth. More...
 
- Static Protected Attributes inherited from CSettings
static size_t m_nWidth = 9
 Comparator network width. More...
 
static size_t m_nDepth = 6
 Comparator network depth. More...
 

Detailed Description

A comparator network, each level of which is represented by a matching stored in an array m_nComparator. There is a comparator between channels j and k at level i-1 iff m_nComparator[i][j] == k and m_nComparator[i][k] == j. Intuitively, m_nComparator[i][j] is the channel that channel j is matched to via a comparator in level i-1.

A sorting network (left) and its representation as an array (right).

For example, in the above diagram at left there is a comparator between channels 0 and 1 at level 1, and in the table at right m_nComparator[0][0] == 1and m_nComparator[0][1] == 0.

Definition at line 47 of file ComparatorNetwork.h.

Constructor & Destructor Documentation

◆ CComparatorNetwork()

CComparatorNetwork::CComparatorNetwork ( )

Initialize the matching array to represent a comparator network with no comparators.

Definition at line 34 of file ComparatorNetwork.cpp.

◆ ~CComparatorNetwork()

CComparatorNetwork::~CComparatorNetwork ( )
virtual

Virtual destructor.

Definition at line 42 of file ComparatorNetwork.cpp.

Member Function Documentation

◆ Save()

void CComparatorNetwork::Save ( const std::string &  fname)

Save comparator network to a text file.

Parameters
fnameFile name string.

Definition at line 48 of file ComparatorNetwork.cpp.

Member Data Documentation

◆ m_nComparator

size_t CComparatorNetwork::m_nComparator[MAXDEPTH][MAXINPUTS] = {0}
protected

Definition at line 49 of file ComparatorNetwork.h.