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