00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef PSET_H
00016 #define PSET_H
00017
00018 #include "dtoolbase.h"
00019 #include "pallocator.h"
00020 #include "stl_compares.h"
00021 #include "register_type.h"
00022
00023 #include <set>
00024 #ifdef HAVE_STL_HASH
00025 #include <hash_set>
00026 #endif
00027
00028 #ifndef USE_STL_ALLOCATOR
00029
00030
00031 #define pset set
00032 #define pmultiset multiset
00033
00034 #ifdef HAVE_STL_HASH
00035 #define phash_set stdext::hash_set
00036 #define phash_multiset stdext::hash_multiset
00037 #else // HAVE_STL_HASH
00038 #define phash_set set
00039 #define phash_multiset multiset
00040 #endif // HAVE_STL_HASH
00041
00042 #else // USE_STL_ALLOCATOR
00043
00044
00045
00046
00047
00048
00049
00050
00051 template<class Key, class Compare = less<Key> >
00052 class pset : public set<Key, Compare, pallocator_single<Key> > {
00053 public:
00054 typedef pallocator_single<Key> allocator;
00055 typedef set<Key, Compare, allocator> base_class;
00056 pset(TypeHandle type_handle = pset_type_handle) : base_class(Compare(), allocator(type_handle)) { }
00057 pset(const pset<Key, Compare> ©) : base_class(copy) { }
00058 pset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : base_class(comp, type_handle) { }
00059
00060 #ifdef USE_TAU
00061 std::pair<TYPENAME base_class::iterator, bool>
00062 insert(const TYPENAME base_class::value_type &x) {
00063 TAU_PROFILE("pset::insert(const value_type &)", " ", TAU_USER);
00064 return base_class::insert(x);
00065 }
00066
00067 TYPENAME base_class::iterator
00068 insert(TYPENAME base_class::iterator position,
00069 const TYPENAME base_class::value_type &x) {
00070 TAU_PROFILE("pset::insert(iterator, const value_type &)", " ", TAU_USER);
00071 return base_class::insert(position, x);
00072 }
00073
00074 void
00075 erase(TYPENAME base_class::iterator position) {
00076 TAU_PROFILE("pset::erase(iterator)", " ", TAU_USER);
00077 base_class::erase(position);
00078 }
00079
00080 TYPENAME base_class::size_type
00081 erase(const TYPENAME base_class::key_type &x) {
00082 TAU_PROFILE("pset::erase(const key_type &)", " ", TAU_USER);
00083 return base_class::erase(x);
00084 }
00085
00086 void
00087 clear() {
00088 TAU_PROFILE("pset::clear()", " ", TAU_USER);
00089 base_class::clear();
00090 }
00091
00092 TYPENAME base_class::iterator
00093 find(const TYPENAME base_class::key_type &x) {
00094 TAU_PROFILE("pset::find(x)", " ", TAU_USER);
00095 return base_class::find(x);
00096 }
00097
00098 TYPENAME base_class::const_iterator
00099 find(const TYPENAME base_class::key_type &x) const {
00100 TAU_PROFILE("pset::find(x)", " ", TAU_USER);
00101 return base_class::find(x);
00102 }
00103 #endif // USE_TAU
00104 };
00105
00106
00107
00108
00109
00110
00111
00112
00113 template<class Key, class Compare = less<Key> >
00114 class pmultiset : public multiset<Key, Compare, pallocator_single<Key> > {
00115 public:
00116 typedef pallocator_single<Key> allocator;
00117 pmultiset(TypeHandle type_handle = pset_type_handle) : multiset<Key, Compare, allocator>(Compare(), allocator(type_handle)) { }
00118 pmultiset(const pmultiset<Key, Compare> ©) : multiset<Key, Compare, allocator>(copy) { }
00119 pmultiset(const Compare &comp, TypeHandle type_handle = pset_type_handle) : multiset<Key, Compare, allocator>(comp, type_handle) { }
00120 };
00121
00122 #ifdef HAVE_STL_HASH
00123
00124
00125
00126
00127
00128
00129
00130 template<class Key, class Compare = method_hash<Key, less<Key> > >
00131 class phash_set : public stdext::hash_set<Key, Compare, pallocator_array<Key> > {
00132 public:
00133 phash_set() : stdext::hash_set<Key, Compare, pallocator_array<Key> >() { }
00134 phash_set(const phash_set<Key, Compare> ©) : stdext::hash_set<Key, Compare, pallocator_array<Key> >(copy) { }
00135 phash_set(const Compare &comp) : stdext::hash_set<Key, Compare, pallocator_array<Key> >(comp) { }
00136 };
00137
00138
00139
00140
00141
00142
00143
00144
00145 template<class Key, class Compare = method_hash<Key, less<Key> > >
00146 class phash_multiset : public stdext::hash_multiset<Key, Compare, pallocator_array<Key> > {
00147 public:
00148 phash_multiset() : stdext::hash_multiset<Key, Compare, pallocator_array<Key> >() { }
00149 phash_multiset(const phash_multiset<Key, Compare> ©) : stdext::hash_multiset<Key, Compare, pallocator_array<Key> >(copy) { }
00150 phash_multiset(const Compare &comp) : stdext::hash_multiset<Key, Compare, pallocator_array<Key> >(comp) { }
00151 };
00152
00153 #else // HAVE_STL_HASH
00154 #define phash_set pset
00155 #define phash_multiset pmultiset
00156 #endif // HAVE_STL_HASH
00157
00158 #endif // USE_STL_ALLOCATOR
00159 #endif