// Created: 27/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleskandars Gluchovas
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXSTLLST_G__
// VERSION:: 0.2 (copy-constructor/assign-op added)
// FOR NOW:: class-member operators "new" and "delete"
-// are ignored by list class, memory allocated
+// are ignored by list class, memory allocated
// and freed using global operators
typedef int Type;
{\
public:\
\
- typedef Type value_type;\
- typedef value_type* pointer;\
- typedef const value_type* const_pointer;\
- typedef value_type& reference;\
- typedef const value_type& const_reference;\
- typedef size_t size_type;\
- typedef ptrdiff_t difference_type;\
+ typedef Type value_type;\
+ typedef value_type* pointer;\
+ typedef const value_type* const_pointer;\
+ typedef value_type& reference;\
+ typedef const value_type& const_reference;\
+ typedef size_t size_type;\
+ typedef ptrdiff_t difference_type;\
\
protected:\
- struct list_node\
- {\
- list_node* mpNext;\
- list_node* mpPrev;\
- value_type mData;\
- };\
-\
- typedef list_node* node_ref_type;\
-\
- node_ref_type mpFreeListHead;\
- node_ref_type mpTerminator;\
- size_type mSize;\
-\
- inline node_ref_type AllocNode() \
- { \
- if ( mpFreeListHead ) \
- {\
- node_ref_type pFreeNode = mpFreeListHead;\
- mpFreeListHead = mpFreeListHead->mpPrev;\
-\
- return pFreeNode;\
- }\
- else\
- {\
- char* pHeapBlock = new char[sizeof(list_node)];\
-\
- return (node_ref_type)pHeapBlock;\
- }\
- }\
-\
- inline void DestroyFreeList()\
- {\
- while ( mpFreeListHead )\
- {\
- node_ref_type tmp = mpFreeListHead;\
+ struct list_node\
+ {\
+ list_node* mpNext;\
+ list_node* mpPrev;\
+ value_type mData;\
+ };\
+\
+ typedef list_node* node_ref_type;\
+\
+ node_ref_type mpFreeListHead;\
+ node_ref_type mpTerminator;\
+ size_type m_Size;\
+\
+ inline node_ref_type AllocNode() \
+ { \
+ if ( mpFreeListHead ) \
+ {\
+ node_ref_type pFreeNode = mpFreeListHead;\
+ mpFreeListHead = mpFreeListHead->mpPrev;\
+\
+ return pFreeNode;\
+ }\
+ else\
+ {\
+ char* pHeapBlock = new char[sizeof(list_node)];\
+\
+ return (node_ref_type)pHeapBlock;\
+ }\
+ }\
+\
+ inline void DestroyFreeList()\
+ {\
+ while ( mpFreeListHead )\
+ {\
+ node_ref_type tmp = mpFreeListHead;\
mpFreeListHead = mpFreeListHead->mpPrev;\
\
delete [](char*)tmp;\
\
inline listClass()\
: mpFreeListHead( 0 ),\
- mSize(0)\
+ m_Size(0)\
{\
mpTerminator = AllocNode();\
mpTerminator->mpPrev = mpTerminator->mpNext = mpTerminator;\
\
inline listClass(const_iterator first, const_iterator last)\
: mpFreeListHead( 0 ),\
- mSize(0)\
+ m_Size(0)\
\
{ while( first != last ) push_back( *first++ ); }\
\
inline const_reverse_iterator rend() const\
{ return const_reverse_iterator(mpTerminator); }\
\
- inline int empty() const { return (mSize == 0); }\
+ inline int empty() const { return (m_Size == 0); }\
\
- inline size_type size() const { return mSize; }\
+ inline size_type size() const { return m_Size; }\
\
inline size_type max_size() const { return UINT_MAX/sizeof(list_node); }\
\
\
new (&pNew->mData) value_type(x);\
\
- ++mSize;\
+ ++m_Size;\
\
return iterator(pNew);\
}\
other.mpTerminator->mpNext = \
other.mpTerminator->mpPrev = other.mpTerminator;\
\
- mSize += other.mSize;\
- other.mSize = 0;\
+ m_Size += other.m_Size;\
+ other.m_Size = 0;\
}\
\
inline void splice( iterator position, listClass& other, iterator first, iterator last )\
++sz;\
}\
\
- mSize += sz;\
- other.mSize -= sz;\
+ m_Size += sz;\
+ other.m_Size -= sz;\
\
node_ref_type pPos = position.mpNode;\
node_ref_type pFirst = first.mpNode;\
\
firstNode = next;\
\
- --mSize;\
+ --m_Size;\
}\
}\
\
\
void sort()\
{\
- if ( mSize < 2 ) return;\
+ if ( m_Size < 2 ) return;\
\
iterator from = begin();\
iterator other_end = end();\
--other_end;\
\
- for( size_type i = 0; i != mSize; ++i )\
+ for( size_type i = 0; i != m_Size; ++i )\
{\
size_type nSwaps = 0;\
\