-void wxList::Sort(const wxSortCompareFunction compfunc)
-{
- // allocate an array for the wxObject pointers of the list
- const size_t num = Number();
- wxObject **objArray = new wxObject *[num];
- wxObject **objPtr = objArray;
-
- // go through the list and put the pointers into the array
- wxNode *node = First();
- while(node!=NULL){
- *objPtr++ = node->Data();
- node = node->Next();
- }
- // sort the array
- qsort((void *)objArray,num,sizeof(wxObject *),compfunc);
- // put the sorted pointers back into the list
- objPtr = objArray;
- node = First();
- while(node!=NULL){
- node->SetData(*objPtr++);
- node = node->Next();
- }
- // free the array
- delete[] objArray;
+void wxListBase::Sort(const wxSortCompareFunction compfunc)
+{
+ // allocate an array for the wxObject pointers of the list
+ const size_t num = GetCount();
+ void **objArray = new void *[num];
+ void **objPtr = objArray;
+
+ // go through the list and put the pointers into the array
+ wxNodeBase *node;
+ for ( node = GetFirst(); node; node = node->GetNext() )
+ {
+ *objPtr++ = node->GetData();
+ }
+
+ // sort the array
+ qsort((void *)objArray,num,sizeof(wxObject *),
+#ifdef __WXWINCE__
+ (int (__cdecl *)(const void *,const void *))
+#endif
+ compfunc);
+
+ // put the sorted pointers back into the list
+ objPtr = objArray;
+ for ( node = GetFirst(); node; node = node->GetNext() )
+ {
+ node->SetData(*objPtr++);
+ }
+
+ // free the array
+ delete[] objArray;
+}
+
+void wxListBase::Reverse()
+{
+ wxNodeBase* node = m_nodeFirst;
+ wxNodeBase* tmp;
+
+ while (node)
+ {
+ // swap prev and next pointers
+ tmp = node->m_next;
+ node->m_next = node->m_previous;
+ node->m_previous = tmp;
+
+ // this is the node that was next before swapping
+ node = tmp;
+ }
+
+ // swap first and last node
+ tmp = m_nodeFirst; m_nodeFirst = m_nodeLast; m_nodeLast = tmp;