X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1b4092eb0b2f823ef3e37a8d9a51c3e12d1438c2..0b746ba80548673d8f9bfed0ea4b1ed45c971ed1:/src/common/list.cpp diff --git a/src/common/list.cpp b/src/common/list.cpp index 041d609db3..f15ace4def 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -38,12 +38,15 @@ #endif // Sun CC compatibility (interference with xview/pkg.h, apparently...) -#if defined(SUN_CC) && defined(__XVIEW__) +// But XView is no longer supported. +/* +#if defined (SUN_CC) || defined(__SUNCC__) && defined(__XVIEW__) #undef va_start #undef va_end #undef va_arg #undef va_list #endif +*/ // ============================================================================= // implementation @@ -142,7 +145,7 @@ int wxNodeBase::IndexOf() const // wxListBase // ----------------------------------------------------------------------------- -void wxListBase::Init(wxKeyType keyType = wxKEY_NONE) +void wxListBase::Init(wxKeyType keyType) { m_nodeFirst = m_nodeLast = (wxNodeBase *) NULL; @@ -289,7 +292,7 @@ wxNodeBase *wxListBase::Item(size_t n) const } } -// wxFAIL_MSG( "invalid index in wxListBase::Item" ); + wxFAIL_MSG( "invalid index in wxListBase::Item" ); return (wxNodeBase *)NULL; } @@ -394,7 +397,6 @@ bool wxListBase::DeleteObject(void *object) return FALSE; } - void wxListBase::Clear() { wxNodeBase *current = m_nodeFirst; @@ -517,6 +519,23 @@ void wxStringListNode::DeleteData() delete [] (char *)GetData(); } +bool wxStringList::Delete(const char *s) +{ + wxStringListNode *current; + + for ( current = GetFirst(); current; current = current->GetNext() ) + { + if ( strcmp(current->GetData(), s) == 0 ) + { + DeleteNode(current); + return TRUE; + } + } + + // not found + return FALSE; +} + void wxStringList::DoCopy(const wxStringList& other) { wxASSERT( GetCount() == 0 ); // this list must be empty before copying! @@ -601,19 +620,20 @@ void wxStringList::Sort() { size_t N = GetCount(); char **array = new char *[N]; + wxStringListNode *node; size_t i = 0; - for ( wxStringListNode *node = GetFirst(); node; node = node->GetNext() ) + for ( node = GetFirst(); node; node = node->GetNext() ) { array[i++] = node->GetData(); } qsort (array, N, sizeof (char *), wx_comparestrings); - Clear(); - for (i = 0; i < N; i++) - Append (array[i]); + i = 0; + for ( node = GetFirst(); node; node = node->GetNext() ) + node->SetData( array[i++] ); - delete[]array; + delete [] array; }