no changes, just reformat/reindent, remove wxT()s
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55763 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -56,7 +56,7 @@ public:
|
||||
bool operator==(const compatibility_iterator& i) const
|
||||
{
|
||||
wxASSERT_MSG( m_list && i.m_list,
|
||||
wxT("comparing invalid iterators is illegal") );
|
||||
"comparing invalid iterators is illegal" );
|
||||
return (m_list == i.m_list) && (m_iter == i.m_iter);
|
||||
}
|
||||
bool operator!=(const compatibility_iterator& i) const
|
||||
@@ -66,16 +66,15 @@ public:
|
||||
bool operator !() const
|
||||
{ return !( operator bool() ); }
|
||||
|
||||
T* GetData() const
|
||||
{ return *m_iter; }
|
||||
void SetData( T* e )
|
||||
{ *m_iter = e; }
|
||||
T* GetData() const { return *m_iter; }
|
||||
void SetData( T* e ) { *m_iter = e; }
|
||||
|
||||
compatibility_iterator GetNext() const
|
||||
{
|
||||
iterator i = m_iter;
|
||||
return compatibility_iterator( m_list, ++i );
|
||||
}
|
||||
|
||||
compatibility_iterator GetPrevious() const
|
||||
{
|
||||
if ( m_iter == m_list->begin() )
|
||||
@@ -84,13 +83,15 @@ public:
|
||||
iterator i = m_iter;
|
||||
return compatibility_iterator( m_list, --i );
|
||||
}
|
||||
|
||||
int IndexOf() const
|
||||
{
|
||||
return *this ? std::distance( m_list->begin(), m_iter )
|
||||
: wxNOT_FOUND;
|
||||
}
|
||||
};
|
||||
public:
|
||||
|
||||
public:
|
||||
wxDList() : m_destroy( false ) {}
|
||||
|
||||
~wxDList() { Clear(); }
|
||||
@@ -98,7 +99,8 @@ public:
|
||||
compatibility_iterator Find( const T* e ) const
|
||||
{
|
||||
return compatibility_iterator( this,
|
||||
std::find( const_cast<ListType*>(this)->begin(), const_cast<ListType*>(this)->end(), e ) );
|
||||
std::find( const_cast<ListType*>(this)->begin(),
|
||||
const_cast<ListType*>(this)->end(), e ) );
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
@@ -112,6 +114,7 @@ public:
|
||||
std::advance( i, idx );
|
||||
return compatibility_iterator( this, i );
|
||||
}
|
||||
|
||||
T* operator[](size_t idx) const
|
||||
{
|
||||
return Item(idx).GetData();
|
||||
@@ -138,15 +141,18 @@ public:
|
||||
this->push_back( e );
|
||||
return GetLast();
|
||||
}
|
||||
|
||||
compatibility_iterator Insert( T* e )
|
||||
{
|
||||
this->push_front( e );
|
||||
return compatibility_iterator( this, this->begin() );
|
||||
}
|
||||
|
||||
compatibility_iterator Insert( compatibility_iterator & i, T* e )
|
||||
{
|
||||
return compatibility_iterator( this, this->insert( i.m_iter, e ) );
|
||||
}
|
||||
|
||||
compatibility_iterator Insert( size_t idx, T* e )
|
||||
{
|
||||
return compatibility_iterator( this,
|
||||
@@ -155,14 +161,17 @@ public:
|
||||
|
||||
void DeleteContents( bool destroy )
|
||||
{ m_destroy = destroy; }
|
||||
|
||||
bool GetDeleteContents() const
|
||||
{ return m_destroy; }
|
||||
|
||||
void Erase( const compatibility_iterator& i )
|
||||
{
|
||||
if ( m_destroy )
|
||||
delete i->GetData();
|
||||
this->erase( i.m_iter );
|
||||
}
|
||||
|
||||
bool DeleteNode( const compatibility_iterator& i )
|
||||
{
|
||||
if( i )
|
||||
@@ -172,10 +181,12 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeleteObject( T* e )
|
||||
{
|
||||
return DeleteNode( Find( e ) );
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if ( m_destroy )
|
||||
@@ -190,15 +201,17 @@ public:
|
||||
|
||||
#else // STL
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
class wxDList
|
||||
{
|
||||
public:
|
||||
class Node
|
||||
{
|
||||
friend class wxDList<T>;
|
||||
public:
|
||||
Node( wxDList<T> *list = NULL, Node *previous = NULL, Node *next = NULL, T *data = NULL )
|
||||
Node(wxDList<T> *list = NULL,
|
||||
Node *previous = NULL,
|
||||
Node *next = NULL,
|
||||
T *data = NULL)
|
||||
{
|
||||
m_list = list;
|
||||
m_previous = previous;
|
||||
@@ -232,7 +245,8 @@ public:
|
||||
|
||||
int IndexOf() const
|
||||
{
|
||||
wxCHECK_MSG( m_list, wxNOT_FOUND, wxT("node doesn't belong to a list in IndexOf"));
|
||||
wxCHECK_MSG( m_list, wxNOT_FOUND,
|
||||
"node doesn't belong to a list in IndexOf" );
|
||||
|
||||
int i;
|
||||
Node *prev = m_previous;
|
||||
@@ -246,6 +260,8 @@ public:
|
||||
Node *m_next, // next and previous nodes in the list
|
||||
*m_previous;
|
||||
wxDList<T> *m_list; // list we belong to
|
||||
|
||||
friend class wxDList<T>;
|
||||
};
|
||||
|
||||
typedef Node nodetype;
|
||||
@@ -256,11 +272,11 @@ public:
|
||||
compatibility_iterator(nodetype *ptr = NULL) : m_ptr(ptr) { }
|
||||
nodetype *operator->() const { return m_ptr; }
|
||||
operator nodetype *() const { return m_ptr; }
|
||||
|
||||
private:
|
||||
nodetype *m_ptr;
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
@@ -284,7 +300,6 @@ private:
|
||||
nodetype *m_nodeFirst, // pointers to the head and tail of the list
|
||||
*m_nodeLast;
|
||||
|
||||
|
||||
public:
|
||||
wxDList()
|
||||
{
|
||||
@@ -326,7 +341,7 @@ public:
|
||||
void Assign(const wxDList<T> &list)
|
||||
{
|
||||
wxASSERT_MSG( !list.m_destroy,
|
||||
wxT("copying list which owns it's elements is a bad idea") );
|
||||
"copying list which owns it's elements is a bad idea" );
|
||||
Clear();
|
||||
m_destroy = list.m_destroy;
|
||||
m_nodeFirst = NULL;
|
||||
@@ -334,7 +349,7 @@ public:
|
||||
nodetype* node;
|
||||
for (node = list.GetFirst(); node; node = node->GetNext() )
|
||||
Append(node->GetData());
|
||||
wxASSERT_MSG( m_count == list.m_count, wxT("logic error in Assign()") );
|
||||
wxASSERT_MSG( m_count == list.m_count, "logic error in Assign()" );
|
||||
}
|
||||
|
||||
nodetype *Append( T *object )
|
||||
@@ -359,6 +374,7 @@ public:
|
||||
{
|
||||
return Insert( NULL, object );
|
||||
}
|
||||
|
||||
nodetype *Insert( size_t pos, T* object )
|
||||
{
|
||||
if (pos == m_count)
|
||||
@@ -366,10 +382,11 @@ public:
|
||||
else
|
||||
return Insert( Item(pos), object );
|
||||
}
|
||||
|
||||
nodetype *Insert( nodetype *position, T* object )
|
||||
{
|
||||
wxCHECK_MSG( !position || position->m_list == this, NULL,
|
||||
wxT("can't insert before a node from another list") );
|
||||
"can't insert before a node from another list" );
|
||||
|
||||
// previous and next node for the node being inserted
|
||||
nodetype *prev, *next;
|
||||
@@ -393,32 +410,13 @@ public:
|
||||
return node;
|
||||
}
|
||||
|
||||
nodetype *GetFirst() const { return m_nodeFirst; }
|
||||
nodetype *GetLast() const { return m_nodeLast; }
|
||||
size_t GetCount() const { return m_count; }
|
||||
bool IsEmpty() const { return m_count == 0; }
|
||||
|
||||
nodetype *GetFirst() const
|
||||
{
|
||||
return m_nodeFirst;
|
||||
}
|
||||
nodetype *GetLast() const
|
||||
{
|
||||
return m_nodeLast;
|
||||
}
|
||||
size_t GetCount() const
|
||||
{
|
||||
return m_count;
|
||||
}
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return m_count == 0;
|
||||
}
|
||||
|
||||
void DeleteContents(bool destroy)
|
||||
{
|
||||
m_destroy = destroy;
|
||||
}
|
||||
bool GetDeleteContents() const
|
||||
{
|
||||
return m_destroy;
|
||||
}
|
||||
void DeleteContents(bool destroy) { m_destroy = destroy; }
|
||||
bool GetDeleteContents() const { return m_destroy; }
|
||||
|
||||
nodetype *Item(size_t index) const
|
||||
{
|
||||
@@ -427,7 +425,7 @@ public:
|
||||
if ( index-- == 0 )
|
||||
return current;
|
||||
}
|
||||
wxFAIL_MSG( wxT("invalid index in Item()") );
|
||||
wxFAIL_MSG( "invalid index in Item()" );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -439,9 +437,9 @@ public:
|
||||
|
||||
nodetype *DetachNode( nodetype *node )
|
||||
{
|
||||
wxCHECK_MSG( node, NULL, wxT("detaching NULL wxNodeBase") );
|
||||
wxCHECK_MSG( node, NULL, "detaching NULL wxNodeBase" );
|
||||
wxCHECK_MSG( node->m_list == this, NULL,
|
||||
wxT("detaching node which is not from this list") );
|
||||
"detaching node which is not from this list" );
|
||||
// update the list
|
||||
nodetype **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next
|
||||
: &m_nodeFirst;
|
||||
@@ -459,6 +457,7 @@ public:
|
||||
{
|
||||
DeleteNode(node);
|
||||
}
|
||||
|
||||
bool DeleteNode( nodetype *node )
|
||||
{
|
||||
if ( !DetachNode(node) )
|
||||
@@ -535,8 +534,6 @@ public:
|
||||
tmp = m_nodeFirst; m_nodeFirst = m_nodeLast; m_nodeLast = tmp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DeleteNodes(nodetype* first, nodetype* last)
|
||||
{
|
||||
nodetype * node = first;
|
||||
@@ -575,7 +572,7 @@ public:
|
||||
}
|
||||
|
||||
/* STL interface */
|
||||
public:
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef int difference_type;
|
||||
typedef T* value_type;
|
||||
@@ -663,6 +660,7 @@ public:
|
||||
bool operator==(const itor& it) const
|
||||
{ return it.m_node == m_node; }
|
||||
};
|
||||
|
||||
class reverse_iterator
|
||||
{
|
||||
public:
|
||||
@@ -701,6 +699,7 @@ public:
|
||||
bool operator==(const itor& it) const
|
||||
{ return it.m_node == m_node; }
|
||||
};
|
||||
|
||||
class const_reverse_iterator
|
||||
{
|
||||
public:
|
||||
@@ -843,6 +842,6 @@ public:
|
||||
} */
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // wxUSE_STL/!wxUSE_STL
|
||||
|
||||
#endif // _WX_DLIST_H_
|
||||
|
Reference in New Issue
Block a user