// Created: 27/09/98
// RCS-ID: $Id$
// Copyright: (c) Aleskandars Gluchovas
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXSTLAC_G__
#endif
#include <stddef.h>
-#include <sys/types.h>
+#if !defined(__WXMAC__) || defined(__DARWIN__)
+# include <sys/types.h>
+#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 ___WXSTL_COMMA ,
-#define __DEFINE_MAP(ARG_IS_UNIQUE, KEY_TYPE, VAL_TYPE, FUNCTOR ) __DEFINE_ASOC_CLASS( ARG_IS_UNIQUE,\
+#define __DEFINE_MAP(ARG_IS_UNIQUE, KEY_TYPE, VAL_TYPE, FUNCTOR ) \
+__DEFINE_ASOC_CLASS( ARG_IS_UNIQUE,\
FUNCTOR,\
__WXSTLMAP_##KEY_TYPE##VAL_TYPE##ARG_IS_UNIQUE, \
struct key_value_pair { KEY_TYPE first ; \
- VAL_TYPE second;\
- key_value_pair() {}\
- key_value_pair( const KEY_TYPE& key ___WXSTL_COMMA const VAL_TYPE& value ) \
- : first(key) ___WXSTL_COMMA second( value ) {} \
- } , \
+ VAL_TYPE second;\
+ key_value_pair() {}\
+ key_value_pair( const KEY_TYPE& key ___WXSTL_COMMA const VAL_TYPE& value ) \
+ : first(key) ___WXSTL_COMMA second( value ) {} \
+ } , \
KEY_TYPE,\
VAL_TYPE,\
mData.first, mData.second, x.first, x.second, \
return result;\
} )
-#define __DEFINE_SET(ARG_IS_UNIQUE, KEY_TYPE, FUNCTOR ) __DEFINE_ASOC_CLASS( ARG_IS_UNIQUE,\
+#define __DEFINE_SET(ARG_IS_UNIQUE, KEY_TYPE, FUNCTOR ) \
+__DEFINE_ASOC_CLASS( ARG_IS_UNIQUE,\
FUNCTOR,\
__WXSTLSET_##TYPE##ARG_IS_UNIQUE, \
KEY_TYPE,\
#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)