00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
#ifndef MN_OS_DICT_BOTH_H
00025
#define MN_OS_DICT_BOTH_H
00026
00027
#include <assert.h>
00028
#include <stdlib.h>
00029
#include <time.h>
00030
00031
00032
00033
00034
00035 typedef void*
d_dic_item;
00036
00037
template <
class K,
class I>
class dictionary;
00038
template <
class K,
class I>
class MNdictionary;
00039
00042
00043
#define d_forall_items(x,S)\
00044
for( x=S.first_item(); x!=NULL; x=S.next_item(x) )
00045
00046
template <
class T,
class M>
00047 inline void*
d_forall_assign(T& r,
void* p,
const M& l) {
00048
if(p)
00049 {
00050 r = l.inf(p);
00051 ASSERT_NON_NULL(r);
00052 }
00053
return p;
00054 }
00055
00060
#define d_forall_var d_forall_runner##__LINE__
00061
00062
#define d_forall(r,l) \
00063
for ( void* \
00064
d_forall_var = d_forall_assign(r,l.first_item(),l); \
00065
d_forall_var != NULL; \
00066
d_forall_var = d_forall_assign(r,l.next_item(d_forall_var),l) )
00067
00068
00069
00077 template <
class K,
class I>
class _d_dic_item
00078 {
00079
private:
00080
_d_dic_item<K,I>* left;
00081
_d_dic_item<K,I>* right;
00082
_d_dic_item<K,I>* father;
00083 K key;
00084 I inf;
00085
int index;
00086
00087 friend class dictionary<K,I>;
00088 friend class MNdictionary<K,I>;
00089
00090
_d_dic_item (
const K& k,
const I& i)
00091 : key(k)
00092 , inf(i)
00093 {
00094 index = rand();
00095 left = NULL;
00096 right = NULL;
00097 father = NULL;
00098 }
00099
public:
00100 inline d_dic_item l() {
return (
d_dic_item)left; };
00101 inline d_dic_item r() {
return (
d_dic_item)right; };
00102 };
00103
00104
#endif
00105