// Created: 27/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleskandars Gluchovas
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXSTLAC_G__
#endif
#include <memory.h>
#include <limits.h>
-#include <new.h>
+/* #include <new.h> */
// the below macro used internally (see actual interface after this macro)
// arguments:
//
-// ARG_IS_UNIQUE
-// ASSOC_CONT_CLASS_NAME
+// ARG_IS_UNIQUE
+// ASSOC_CONT_CLASS_NAME
//
-// ARG_VALUE_TYPE
+// ARG_VALUE_TYPE
// ARG_KEY_TYPE
// ARG_ACTUAL_VALUE_TYPE
-//
+//
// _KEY_NAME
// _VALUE_NAME
//
-// _X_KEY_NAME
-// _X_VALUE_NAME
+// _X_KEY_NAME
+// _X_VALUE_NAME
//
// _INSERT_METHOD_DEFINITION
protected:\
\
public:\
- typedef ARG_VALUE_TYPE value_type;\
- typedef ARG_KEY_TYPE key_type;\
- typedef ARG_ACTUAL_VALUE_TYPE actual_value_type;\
+ typedef ARG_VALUE_TYPE value_type;\
+ typedef ARG_KEY_TYPE key_type;\
+ typedef ARG_ACTUAL_VALUE_TYPE actual_value_type;\
\
typedef value_type* pointer;\
typedef value_type& reference;\
\
struct tree_node \
{\
- tree_node* mpParent;\
+ tree_node* m_pParent;\
tree_node* mpLeft;\
tree_node* mpRight;\
\
value_type mData;\
};\
\
+public:\
typedef tree_node* node_ref_type;\
+protected:\
\
node_ref_type mpRoot;\
node_ref_type mpLeftMost;\
return pNode;\
}\
else\
- if ( pNode->mpParent )\
+ if ( pNode->m_pParent )\
{\
- if ( pNode == pNode->mpParent->mpLeft )\
+ if ( pNode == pNode->m_pParent->mpLeft )\
\
- return pNode->mpParent;\
+ return pNode->m_pParent;\
\
- pNode = pNode->mpParent;\
+ pNode = pNode->m_pParent;\
\
node_ref_type prevNode = pNode;\
- pNode = pNode->mpParent;\
+ pNode = pNode->m_pParent;\
\
while(pNode)\
{\
) return pNode;\
\
prevNode = pNode;\
- pNode= pNode->mpParent;\
+ pNode= pNode->m_pParent;\
}\
\
return 0;\
return pNode;\
}\
else\
- if ( pNode->mpParent )\
+ if ( pNode->m_pParent )\
{\
- if ( pNode == pNode->mpParent->mpRight )\
- return pNode->mpParent;\
+ if ( pNode == pNode->m_pParent->mpRight )\
+ return pNode->m_pParent;\
\
- pNode = pNode->mpParent;\
+ pNode = pNode->m_pParent;\
\
node_ref_type prevNode = pNode;\
- pNode = pNode->mpParent;\
+ pNode = pNode->m_pParent;\
\
while(pNode)\
{\
) return pNode;\
\
prevNode = pNode;\
- pNode= pNode->mpParent;\
+ pNode= pNode->m_pParent;\
}\
\
return 0;\
{\
node_ref_type pNewNode = AllocNode();\
\
- pNewNode->mpParent = \
+ pNewNode->m_pParent = \
pNewNode->mpLeft =\
pNewNode->mpRight = 0;\
\
: pCurrent->mpRight;\
}\
\
- pNewNode->mpParent = pParent;\
+ pNewNode->m_pParent = pParent;\
\
if(pParent)\
\
else\
pX = pY->mpRight;\
\
- if ( pX ) pX->mpParent = pY->mpParent;\
+ if ( pX ) pX->m_pParent = pY->m_pParent;\
\
- if (pY->mpParent)\
+ if (pY->m_pParent)\
\
- if (pY == pY->mpParent->mpLeft )\
+ if (pY == pY->m_pParent->mpLeft )\
\
- pY->mpParent->mpLeft = pX;\
+ pY->m_pParent->mpLeft = pX;\
else\
- pY->mpParent->mpRight = pX;\
+ pY->m_pParent->mpRight = pX;\
else\
mpRoot = pX;\
\
\
pY->mpLeft = pZ->mpLeft;\
\
- if (pY->mpLeft) pY->mpLeft->mpParent = pY;\
+ if (pY->mpLeft) pY->mpLeft->m_pParent = pY;\
\
pY->mpRight = pZ->mpRight;\
\
if ( pY->mpRight ) \
\
- pY->mpRight->mpParent = pY;\
+ pY->mpRight->m_pParent = pY;\
\
- pY->mpParent = pZ->mpParent;\
+ pY->m_pParent = pZ->m_pParent;\
\
- if (pZ->mpParent)\
+ if (pZ->m_pParent)\
\
- if (pZ == pZ->mpParent->mpLeft)\
+ if (pZ == pZ->m_pParent->mpLeft)\
\
- pZ->mpParent->mpLeft = pY;\
+ pZ->m_pParent->mpLeft = pY;\
else\
- pZ->mpParent->mpRight = pY;\
+ pZ->m_pParent->mpRight = pY;\
else\
mpRoot = pY;\
\
#define GREATER_THEN_FUNCTOR(TYPE) struct \
{ inline int operator()(const TYPE& x, const TYPE& y ) const { return x > y; } }
-// functor argument should be created using the two above macros
+// functor argument should be created using the two above macros
// or passing own class with method "operator()(const TYPE&,cosnt TYPE&)" defined in it
#define WXSTL_MAP( KEY_TYPE, VALUE_TYPE, FUNCTOR ) __DEFINE_MAP( 1 ,KEY_TYPE, VALUE_TYPE, FUNCTOR)