int main()
{
	SetArraySize(2);
	assert( 2 == g_arraysize); // test-driven development (TDD)
	assert( 0 == p_arraydata[1]);

	SetValue( 0, 1.0);
	SetValue( 1, 2.0);
	assert( 2.0 == p_arraydata[1]);

	PrintArray();

	FreeArray();
	assert ( 0 == g_arraysize);
	assert ( 0 == p_arraydata);

    return 0;
}
Пример #2
0
void WMain::OnArraySizeSliderChange(wxScrollEvent &event)
{
    SetArraySize(event.GetPosition());
}
Пример #3
0
WMain::WMain(wxWindow* parent)
    : WMain_wxg(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE)
{
    m_thread = NULL;
    g_sound_on = false;

    recordButton->Hide();
    panelQuickSortPivot->Hide();
    infoTextctrl->Hide();

    // program icon
    {    
        #include "sos.xpm"
	SetIcon( wxIcon(sos) );
    }

    // program version
    SetTitle(_("The Sound of Sorting " VERSION " - http://panthema.net/2013/sound-of-sorting"));

    // resize right split window
    splitter_0->SetSashPosition(GetSize().x - 280);

    // insert list of algorithms into wxListBox
    for (const AlgoEntry* ae = g_algolist; ae->name; ++ae)
        algoList->Append(ae->name);
    algoList->SetSelection(0);

    // insert list of data templates into wxChoice
    sortview->FillInputlist(inputTypeChoice);
    sortview->FillData(0, 100);
    inputTypeChoice->SetSelection(0);
    arraySizeSlider->SetValue(100);
    SetArraySize(100);

    // insert quicksort pivot rules into wxChoice
    for (const wxChar** pt = g_quicksort_pivot_text; *pt; ++pt)
        pivotRuleChoice->Append(*pt);
    pivotRuleChoice->SetSelection(0);

    // set default speed
    speedSlider->SetValue(1000);
    SetDelay(1000);

    // set default sound sustain
    soundSustainSlider->SetValue(700);
    SetSoundSustain(700);

    // create audio output
    SDL_AudioSpec sdlaudiospec;

    // Set the audio format
    sdlaudiospec.freq = 44100;
    sdlaudiospec.format = AUDIO_S16SYS;
    sdlaudiospec.channels = 1;    	/* 1 = mono, 2 = stereo */
    sdlaudiospec.samples = 4096;  	/* Good low-latency value for callback */
    sdlaudiospec.callback = SoundCallback;
    sdlaudiospec.userdata = sortview;

    // Open the audio device, forcing the desired format
    if ( SDL_OpenAudio(&sdlaudiospec, NULL) < 0 ) {
        wxLogError(_("Couldn't open audio: ") + wxString(SDL_GetError(), wxConvISO8859_1));
        soundButton->Disable();
    }
    soundButton->SetValue(false);

    Show();

    // start refreshing timer
    m_reftimer = new RefreshTimer(this);
    m_reftimer->Start(1000 / g_framerate);
}