![]() |
Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
|
The main class. More...
#include <CMain.h>
Public Member Functions | |
CMain (const HWND) | |
Constructor. More... | |
~CMain () | |
Destructor. More... | |
template<class t > | |
void | GeneratePowerOf2 () |
Generate sorting network. More... | |
template<class t > | |
void | Generate () |
Generate sorting network. More... | |
void | Read () |
Read comparator network from file. More... | |
void | Draw () |
Draw comparator network to bitmap. More... | |
bool | Verify () |
Verify that comparator network sorts. More... | |
void | OnPaint () |
Paint the client area of the window. More... | |
Gdiplus::Bitmap * | GetBitmap () |
Get pointer to bitmap. More... | |
void | SetDrawStyle (const eDrawStyle) |
Set drawing style. More... | |
HRESULT | Export (const eExport) |
Export image file. More... | |
Private Member Functions | |
void | CreateMenus () |
Create menus. More... | |
void | EnableMenus () |
Enable menus. More... | |
Private Attributes | |
HWND | m_hWnd = nullptr |
Window handle. More... | |
ULONG_PTR | m_gdiplusToken = 0 |
GDI+ token. More... | |
HMENU | m_hMenuBar = nullptr |
Handle to the menu bar. More... | |
std::wstring | m_wstrName = L"Default" |
File name. More... | |
eDrawStyle | m_eDrawStyle = eDrawStyle::Horizontal |
Drawing style. More... | |
CSortingNetwork * | m_pSortingNetwork = nullptr |
Pointer to the sorting network. More... | |
The interface between I/O from Windows (input from the drop-down menus, output to the client area of the window) and the GDI+ graphics interface.
CMain::CMain | ( | const HWND | hwnd | ) |
CMain::~CMain | ( | ) |
|
private |
void CMain::Draw | ( | ) |
|
private |
HRESULT CMain::Export | ( | const eExport | t | ) |
template void CMain::Generate< CBubbleSort > | ( | ) |
Generate bubblesort.
Generate max-bubblesort.
Generate min-bubblesort.
Pop up a custom dialog box asking for the number of inputs. If successful and in range, then generate a sorting network with that number of inputs.
t | Class of sorting network to generate. |
template void CMain::GeneratePowerOf2< CPairwiseSort > | ( | ) |
Generate pairwise.
Generate bitonic.
Generate odd-even.
Pop up a custom dialog box asking for the number of inputs. If successful and in range, then round the number of inputs up to the closest power of 2, generate a sorting network of that size, then prune away unneeded channels and comparators.
t | Class of sorting network to generate. |
Gdiplus::Bitmap * CMain::GetBitmap | ( | ) |
void CMain::OnPaint | ( | ) |
void CMain::Read | ( | ) |
Attempt to read a comparator network from a file into a new instance of CSortingNetwork
and put a pointer to it in m_pSortingNetwork
. If successful, then enable the menu items that are grayed out by default until a comparator network is successully loaded. Otherwise set m_pSortingNetwork
to nullptr
.
void CMain::SetDrawStyle | ( | const eDrawStyle | d | ) |
bool CMain::Verify | ( | ) |
Pop up a message box that tells the user information about the comparator network and whether or not it is a sorting network. The latter will take time exponential in the number of inputs, which is probably the best we can do because sorting network verification is Co-NP-complete even for shallow sorting networks (see the following paper).
I. Parberry. "Single-exception sorting networks and the computational complexity of optimal sorting network verification", Mathematical Systems Theory, Vol. 23, No. 1, pp. 81–93, 1990.
If the number of inputs to the sorting network is 30 or larger, the user is given the option of whether or not to proceed with verification via a Yes/No dialog box.
|
private |
|
private |