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
|
bool operator==(const compatibility_iterator& i) const
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( m_list && i.m_list,
|
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);
|
return (m_list == i.m_list) && (m_iter == i.m_iter);
|
||||||
}
|
}
|
||||||
bool operator!=(const compatibility_iterator& i) const
|
bool operator!=(const compatibility_iterator& i) const
|
||||||
@@ -66,16 +66,15 @@ public:
|
|||||||
bool operator !() const
|
bool operator !() const
|
||||||
{ return !( operator bool() ); }
|
{ return !( operator bool() ); }
|
||||||
|
|
||||||
T* GetData() const
|
T* GetData() const { return *m_iter; }
|
||||||
{ return *m_iter; }
|
void SetData( T* e ) { *m_iter = e; }
|
||||||
void SetData( T* e )
|
|
||||||
{ *m_iter = e; }
|
|
||||||
|
|
||||||
compatibility_iterator GetNext() const
|
compatibility_iterator GetNext() const
|
||||||
{
|
{
|
||||||
iterator i = m_iter;
|
iterator i = m_iter;
|
||||||
return compatibility_iterator( m_list, ++i );
|
return compatibility_iterator( m_list, ++i );
|
||||||
}
|
}
|
||||||
|
|
||||||
compatibility_iterator GetPrevious() const
|
compatibility_iterator GetPrevious() const
|
||||||
{
|
{
|
||||||
if ( m_iter == m_list->begin() )
|
if ( m_iter == m_list->begin() )
|
||||||
@@ -84,13 +83,15 @@ public:
|
|||||||
iterator i = m_iter;
|
iterator i = m_iter;
|
||||||
return compatibility_iterator( m_list, --i );
|
return compatibility_iterator( m_list, --i );
|
||||||
}
|
}
|
||||||
|
|
||||||
int IndexOf() const
|
int IndexOf() const
|
||||||
{
|
{
|
||||||
return *this ? std::distance( m_list->begin(), m_iter )
|
return *this ? std::distance( m_list->begin(), m_iter )
|
||||||
: wxNOT_FOUND;
|
: wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public:
|
|
||||||
|
public:
|
||||||
wxDList() : m_destroy( false ) {}
|
wxDList() : m_destroy( false ) {}
|
||||||
|
|
||||||
~wxDList() { Clear(); }
|
~wxDList() { Clear(); }
|
||||||
@@ -98,7 +99,8 @@ public:
|
|||||||
compatibility_iterator Find( const T* e ) const
|
compatibility_iterator Find( const T* e ) const
|
||||||
{
|
{
|
||||||
return compatibility_iterator( this,
|
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
|
bool IsEmpty() const
|
||||||
@@ -112,6 +114,7 @@ public:
|
|||||||
std::advance( i, idx );
|
std::advance( i, idx );
|
||||||
return compatibility_iterator( this, i );
|
return compatibility_iterator( this, i );
|
||||||
}
|
}
|
||||||
|
|
||||||
T* operator[](size_t idx) const
|
T* operator[](size_t idx) const
|
||||||
{
|
{
|
||||||
return Item(idx).GetData();
|
return Item(idx).GetData();
|
||||||
@@ -138,15 +141,18 @@ public:
|
|||||||
this->push_back( e );
|
this->push_back( e );
|
||||||
return GetLast();
|
return GetLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
compatibility_iterator Insert( T* e )
|
compatibility_iterator Insert( T* e )
|
||||||
{
|
{
|
||||||
this->push_front( e );
|
this->push_front( e );
|
||||||
return compatibility_iterator( this, this->begin() );
|
return compatibility_iterator( this, this->begin() );
|
||||||
}
|
}
|
||||||
|
|
||||||
compatibility_iterator Insert( compatibility_iterator & i, T* e )
|
compatibility_iterator Insert( compatibility_iterator & i, T* e )
|
||||||
{
|
{
|
||||||
return compatibility_iterator( this, this->insert( i.m_iter, e ) );
|
return compatibility_iterator( this, this->insert( i.m_iter, e ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
compatibility_iterator Insert( size_t idx, T* e )
|
compatibility_iterator Insert( size_t idx, T* e )
|
||||||
{
|
{
|
||||||
return compatibility_iterator( this,
|
return compatibility_iterator( this,
|
||||||
@@ -155,14 +161,17 @@ public:
|
|||||||
|
|
||||||
void DeleteContents( bool destroy )
|
void DeleteContents( bool destroy )
|
||||||
{ m_destroy = destroy; }
|
{ m_destroy = destroy; }
|
||||||
|
|
||||||
bool GetDeleteContents() const
|
bool GetDeleteContents() const
|
||||||
{ return m_destroy; }
|
{ return m_destroy; }
|
||||||
|
|
||||||
void Erase( const compatibility_iterator& i )
|
void Erase( const compatibility_iterator& i )
|
||||||
{
|
{
|
||||||
if ( m_destroy )
|
if ( m_destroy )
|
||||||
delete i->GetData();
|
delete i->GetData();
|
||||||
this->erase( i.m_iter );
|
this->erase( i.m_iter );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeleteNode( const compatibility_iterator& i )
|
bool DeleteNode( const compatibility_iterator& i )
|
||||||
{
|
{
|
||||||
if( i )
|
if( i )
|
||||||
@@ -172,10 +181,12 @@ public:
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeleteObject( T* e )
|
bool DeleteObject( T* e )
|
||||||
{
|
{
|
||||||
return DeleteNode( Find( e ) );
|
return DeleteNode( Find( e ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
if ( m_destroy )
|
if ( m_destroy )
|
||||||
@@ -190,15 +201,17 @@ public:
|
|||||||
|
|
||||||
#else // STL
|
#else // STL
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
class wxDList
|
class wxDList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
friend class wxDList<T>;
|
|
||||||
public:
|
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_list = list;
|
||||||
m_previous = previous;
|
m_previous = previous;
|
||||||
@@ -232,7 +245,8 @@ public:
|
|||||||
|
|
||||||
int IndexOf() const
|
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;
|
int i;
|
||||||
Node *prev = m_previous;
|
Node *prev = m_previous;
|
||||||
@@ -246,6 +260,8 @@ public:
|
|||||||
Node *m_next, // next and previous nodes in the list
|
Node *m_next, // next and previous nodes in the list
|
||||||
*m_previous;
|
*m_previous;
|
||||||
wxDList<T> *m_list; // list we belong to
|
wxDList<T> *m_list; // list we belong to
|
||||||
|
|
||||||
|
friend class wxDList<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Node nodetype;
|
typedef Node nodetype;
|
||||||
@@ -256,11 +272,11 @@ public:
|
|||||||
compatibility_iterator(nodetype *ptr = NULL) : m_ptr(ptr) { }
|
compatibility_iterator(nodetype *ptr = NULL) : m_ptr(ptr) { }
|
||||||
nodetype *operator->() const { return m_ptr; }
|
nodetype *operator->() const { return m_ptr; }
|
||||||
operator nodetype *() const { return m_ptr; }
|
operator nodetype *() const { return m_ptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nodetype *m_ptr;
|
nodetype *m_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
@@ -284,7 +300,6 @@ private:
|
|||||||
nodetype *m_nodeFirst, // pointers to the head and tail of the list
|
nodetype *m_nodeFirst, // pointers to the head and tail of the list
|
||||||
*m_nodeLast;
|
*m_nodeLast;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxDList()
|
wxDList()
|
||||||
{
|
{
|
||||||
@@ -326,7 +341,7 @@ public:
|
|||||||
void Assign(const wxDList<T> &list)
|
void Assign(const wxDList<T> &list)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !list.m_destroy,
|
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();
|
Clear();
|
||||||
m_destroy = list.m_destroy;
|
m_destroy = list.m_destroy;
|
||||||
m_nodeFirst = NULL;
|
m_nodeFirst = NULL;
|
||||||
@@ -334,7 +349,7 @@ public:
|
|||||||
nodetype* node;
|
nodetype* node;
|
||||||
for (node = list.GetFirst(); node; node = node->GetNext() )
|
for (node = list.GetFirst(); node; node = node->GetNext() )
|
||||||
Append(node->GetData());
|
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 )
|
nodetype *Append( T *object )
|
||||||
@@ -359,6 +374,7 @@ public:
|
|||||||
{
|
{
|
||||||
return Insert( NULL, object );
|
return Insert( NULL, object );
|
||||||
}
|
}
|
||||||
|
|
||||||
nodetype *Insert( size_t pos, T* object )
|
nodetype *Insert( size_t pos, T* object )
|
||||||
{
|
{
|
||||||
if (pos == m_count)
|
if (pos == m_count)
|
||||||
@@ -366,10 +382,11 @@ public:
|
|||||||
else
|
else
|
||||||
return Insert( Item(pos), object );
|
return Insert( Item(pos), object );
|
||||||
}
|
}
|
||||||
|
|
||||||
nodetype *Insert( nodetype *position, T* object )
|
nodetype *Insert( nodetype *position, T* object )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( !position || position->m_list == this, NULL,
|
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
|
// previous and next node for the node being inserted
|
||||||
nodetype *prev, *next;
|
nodetype *prev, *next;
|
||||||
@@ -393,32 +410,13 @@ public:
|
|||||||
return node;
|
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
|
void DeleteContents(bool destroy) { m_destroy = destroy; }
|
||||||
{
|
bool GetDeleteContents() const { return m_destroy; }
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
nodetype *Item(size_t index) const
|
nodetype *Item(size_t index) const
|
||||||
{
|
{
|
||||||
@@ -427,7 +425,7 @@ public:
|
|||||||
if ( index-- == 0 )
|
if ( index-- == 0 )
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
wxFAIL_MSG( wxT("invalid index in Item()") );
|
wxFAIL_MSG( "invalid index in Item()" );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,9 +437,9 @@ public:
|
|||||||
|
|
||||||
nodetype *DetachNode( nodetype *node )
|
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,
|
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
|
// update the list
|
||||||
nodetype **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next
|
nodetype **prevNext = node->GetPrevious() ? &node->GetPrevious()->m_next
|
||||||
: &m_nodeFirst;
|
: &m_nodeFirst;
|
||||||
@@ -459,6 +457,7 @@ public:
|
|||||||
{
|
{
|
||||||
DeleteNode(node);
|
DeleteNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeleteNode( nodetype *node )
|
bool DeleteNode( nodetype *node )
|
||||||
{
|
{
|
||||||
if ( !DetachNode(node) )
|
if ( !DetachNode(node) )
|
||||||
@@ -535,8 +534,6 @@ public:
|
|||||||
tmp = m_nodeFirst; m_nodeFirst = m_nodeLast; m_nodeLast = tmp;
|
tmp = m_nodeFirst; m_nodeFirst = m_nodeLast; m_nodeLast = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void DeleteNodes(nodetype* first, nodetype* last)
|
void DeleteNodes(nodetype* first, nodetype* last)
|
||||||
{
|
{
|
||||||
nodetype * node = first;
|
nodetype * node = first;
|
||||||
@@ -575,7 +572,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* STL interface */
|
/* STL interface */
|
||||||
public:
|
public:
|
||||||
typedef size_t size_type;
|
typedef size_t size_type;
|
||||||
typedef int difference_type;
|
typedef int difference_type;
|
||||||
typedef T* value_type;
|
typedef T* value_type;
|
||||||
@@ -663,6 +660,7 @@ public:
|
|||||||
bool operator==(const itor& it) const
|
bool operator==(const itor& it) const
|
||||||
{ return it.m_node == m_node; }
|
{ return it.m_node == m_node; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class reverse_iterator
|
class reverse_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -701,6 +699,7 @@ public:
|
|||||||
bool operator==(const itor& it) const
|
bool operator==(const itor& it) const
|
||||||
{ return it.m_node == m_node; }
|
{ return it.m_node == m_node; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class const_reverse_iterator
|
class const_reverse_iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -843,6 +842,6 @@ public:
|
|||||||
} */
|
} */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // wxUSE_STL/!wxUSE_STL
|
||||||
|
|
||||||
#endif // _WX_DLIST_H_
|
#endif // _WX_DLIST_H_
|
||||||
|
Reference in New Issue
Block a user