00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ACE_UNBOUNDED_SET_EX_H
00014 #define ACE_UNBOUNDED_SET_EX_H
00015 #include "ace/pre.h"
00016
00017 #include "ace/Node.h"
00018 #include "ace/os_include/os_stddef.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025
00026 class ACE_Allocator;
00027
00028 template <class T, class C>
00029 class ACE_Unbounded_Set_Ex_Iterator;
00030
00031 template <class T, class C>
00032 class ACE_Unbounded_Set_Ex_Const_Iterator;
00033
00034 template <class T, class C>
00035 class ACE_Unbounded_Set_Ex;
00036
00037
00038
00039
00040
00041
00042 template <class T, class C>
00043 class ACE_Unbounded_Set_Ex_Iterator
00044 {
00045 public:
00046
00047 ACE_Unbounded_Set_Ex_Iterator (ACE_Unbounded_Set_Ex<T, C> &s, bool end = false);
00048
00049
00050
00051
00052
00053 int next (T *&next_item);
00054
00055
00056
00057 int advance (void);
00058
00059
00060
00061 int first (void);
00062
00063
00064 int done (void) const;
00065
00066
00067 void dump (void) const;
00068
00069
00070
00071
00072 ACE_Unbounded_Set_Ex_Iterator<T, C> operator++ (int);
00073
00074
00075 ACE_Unbounded_Set_Ex_Iterator<T, C>& operator++ (void);
00076
00077
00078 T& operator* (void);
00079
00080
00081 bool operator== (const ACE_Unbounded_Set_Ex_Iterator<T, C> &) const;
00082 bool operator!= (const ACE_Unbounded_Set_Ex_Iterator<T, C> &) const;
00083
00084
00085 ACE_ALLOC_HOOK_DECLARE;
00086
00087 private:
00088
00089
00090 ACE_Node<T, C> *current_;
00091
00092
00093 ACE_Unbounded_Set_Ex<T, C> *set_;
00094 };
00095
00096
00097
00098
00099
00100
00101 template <class T, class C>
00102 class ACE_Unbounded_Set_Ex_Const_Iterator
00103 {
00104 public:
00105
00106 ACE_Unbounded_Set_Ex_Const_Iterator (const ACE_Unbounded_Set_Ex<T, C> &s,
00107 bool end = false);
00108
00109
00110
00111
00112
00113 int next (T *&next_item);
00114
00115
00116
00117 int advance (void);
00118
00119
00120
00121 int first (void);
00122
00123
00124 int done (void) const;
00125
00126
00127 void dump (void) const;
00128
00129
00130
00131
00132 ACE_Unbounded_Set_Ex_Const_Iterator<T, C> operator++ (int);
00133
00134
00135 ACE_Unbounded_Set_Ex_Const_Iterator<T, C>& operator++ (void);
00136
00137
00138 T& operator* (void);
00139
00140
00141 bool operator== (const ACE_Unbounded_Set_Ex_Const_Iterator<T, C> &) const;
00142 bool operator!= (const ACE_Unbounded_Set_Ex_Const_Iterator<T, C> &) const;
00143
00144
00145 ACE_ALLOC_HOOK_DECLARE;
00146
00147 private:
00148
00149
00150 ACE_Node<T, C> *current_;
00151
00152
00153 const ACE_Unbounded_Set_Ex<T, C> *set_;
00154 };
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 template <class T, class C>
00195 class ACE_Unbounded_Set_Ex
00196 {
00197 public:
00198 friend class ACE_Unbounded_Set_Ex_Iterator<T, C>;
00199 friend class ACE_Unbounded_Set_Ex_Const_Iterator<T, C>;
00200
00201
00202 typedef ACE_Unbounded_Set_Ex_Iterator<T, C> ITERATOR;
00203 typedef ACE_Unbounded_Set_Ex_Iterator<T, C> iterator;
00204 typedef ACE_Unbounded_Set_Ex_Const_Iterator<T, C> CONST_ITERATOR;
00205 typedef ACE_Unbounded_Set_Ex_Const_Iterator<T, C> const_iterator;
00206 typedef C COMP;
00207 typedef ACE_Node<T, C> NODE;
00208
00209
00210
00211
00212
00213
00214
00215
00216 ACE_Unbounded_Set_Ex (ACE_Allocator *alloc = 0);
00217
00218
00219
00220
00221
00222 ACE_Unbounded_Set_Ex (const C &comparator, ACE_Allocator *alloc = 0);
00223
00224
00225
00226
00227
00228 ACE_Unbounded_Set_Ex (const ACE_Unbounded_Set_Ex<T, C> &);
00229
00230
00231
00232
00233
00234 ACE_Unbounded_Set_Ex<T, C> & operator= (const ACE_Unbounded_Set_Ex<T, C> &);
00235
00236
00237
00238
00239
00240 ~ACE_Unbounded_Set_Ex (void);
00241
00242
00243
00244
00245
00246
00247
00248 bool is_empty (void) const;
00249
00250
00251
00252
00253
00254 bool is_full (void) const;
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 int insert (const T &new_item);
00265
00266
00267
00268
00269
00270
00271 int insert_tail (const T &item);
00272
00273
00274
00275
00276
00277
00278
00279 int remove (const T &item);
00280
00281
00282
00283
00284
00285
00286 int find (const T &item) const;
00287
00288
00289
00290
00291
00292 size_t size (void) const;
00293
00294
00295 void dump (void) const;
00296
00297
00298
00299
00300
00301 void reset (void);
00302
00303
00304 iterator begin (void);
00305 iterator end (void);
00306 const_iterator begin (void) const;
00307 const_iterator end (void) const;
00308
00309
00310 ACE_ALLOC_HOOK_DECLARE;
00311
00312 private:
00313
00314 void delete_nodes (void);
00315
00316
00317 void copy_nodes (const ACE_Unbounded_Set_Ex<T, C> &);
00318
00319
00320 NODE *head_;
00321
00322
00323 size_t cur_size_;
00324
00325
00326 ACE_Allocator *allocator_;
00327
00328
00329 COMP comp_;
00330 };
00331
00332 ACE_END_VERSIONED_NAMESPACE_DECL
00333
00334 #if defined (__ACE_INLINE__)
00335 #include "ace/Unbounded_Set_Ex.inl"
00336 #endif
00337
00338 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00339 #include "ace/Unbounded_Set_Ex.cpp"
00340 #endif
00341
00342 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00343 #pragma implementation ("Unbounded_Set_Ex.cpp")
00344 #endif
00345
00346 #include "ace/post.h"
00347 #endif