1. made wxBase compile/link/run again under Unix
2. added wxSortedArrayString class and documented it git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4128 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,11 +9,38 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <wx/string.h>
|
||||
#include <wx/file.h>
|
||||
#include <wx/app.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// conditional compilation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// what to test?
|
||||
#define TEST_ARRAYS
|
||||
#undef TEST_THREADS
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// threads
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_THREADS
|
||||
|
||||
#include <wx/thread.h>
|
||||
|
||||
static size_t gs_counter = (size_t)-1;
|
||||
@@ -71,6 +98,31 @@ void MyThread::OnExit()
|
||||
gs_counter--;
|
||||
}
|
||||
|
||||
#endif // TEST_THREADS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// arrays
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef TEST_ARRAYS
|
||||
|
||||
void PrintArray(const char* name, const wxArrayString& array)
|
||||
{
|
||||
printf("Dump of the array '%s'\n", name);
|
||||
|
||||
size_t nCount = array.GetCount();
|
||||
for ( size_t n = 0; n < nCount; n++ )
|
||||
{
|
||||
printf("\t%s[%u] = '%s'\n", name, n, array[n].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TEST_ARRAYS
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// entry point
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
if ( !wxInitialize() )
|
||||
@@ -78,6 +130,39 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Failed to initialize the wxWindows library, aborting.");
|
||||
}
|
||||
|
||||
#ifdef TEST_ARRAYS
|
||||
wxArrayString a1;
|
||||
a1.Add("tiger");
|
||||
a1.Add("cat");
|
||||
a1.Add("lion");
|
||||
a1.Add("dog");
|
||||
a1.Add("human");
|
||||
a1.Add("ape");
|
||||
|
||||
puts("*** Initially:");
|
||||
|
||||
PrintArray("a1", a1);
|
||||
|
||||
wxArrayString a2(a1);
|
||||
PrintArray("a2", a2);
|
||||
|
||||
wxSortedArrayString a3(a1);
|
||||
PrintArray("a3", a3);
|
||||
|
||||
puts("*** After deleting a string from a1");
|
||||
a1.Remove(2);
|
||||
|
||||
PrintArray("a1", a1);
|
||||
PrintArray("a2", a2);
|
||||
PrintArray("a3", a3);
|
||||
|
||||
puts("*** After reassigning a1 to a2 and a3");
|
||||
a3 = a2 = a1;
|
||||
PrintArray("a2", a2);
|
||||
PrintArray("a3", a3);
|
||||
#endif // TEST_ARRAYS
|
||||
|
||||
#ifdef TEST_THREADS
|
||||
static const size_t nThreads = 3;
|
||||
MyThread *threads[nThreads];
|
||||
size_t n;
|
||||
@@ -101,6 +186,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
threads[n]->Delete();
|
||||
}
|
||||
#endif // TEST_THREADS
|
||||
|
||||
wxUninitialize();
|
||||
|
||||
|
Reference in New Issue
Block a user