00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COH_LINKED_LIST_HPP
00017 #define COH_LINKED_LIST_HPP
00018
00019 #include "coherence/lang.ns"
00020
00021 #include "coherence/util/Collection.hpp"
00022 #include "coherence/util/ListIterator.hpp"
00023 #include "coherence/util/AbstractList.hpp"
00024 #include "coherence/util/SubList.hpp"
00025
00026 COH_OPEN_NAMESPACE2(coherence,util)
00027
00028
00029
00030
00031
00032
00033
00034 class COH_EXPORT LinkedList
00035 : public cloneable_spec<LinkedList,
00036 extends<AbstractList> >
00037 {
00038 friend class factory<LinkedList>;
00039
00040
00041
00042 protected:
00043
00044
00045
00046
00047
00048 LinkedList();
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 LinkedList(Collection::View vc);
00059
00060
00061
00062
00063 LinkedList(const LinkedList& that);
00064
00065
00066
00067
00068 virtual ~LinkedList();
00069
00070
00071
00072
00073 public:
00074
00075
00076
00077 virtual bool add(size32_t i, Object::Holder oh);
00078
00079
00080
00081
00082 virtual bool addAll(size32_t i, Collection::View vc);
00083
00084
00085
00086
00087 virtual Object::Holder get(size32_t i) const;
00088
00089
00090
00091
00092 using List::get;
00093
00094
00095
00096
00097 virtual size32_t indexOf(Object::View v) const;
00098
00099
00100
00101
00102 virtual size32_t lastIndexOf(Object::View v) const;
00103
00104
00105
00106
00107 virtual ListIterator::Handle listIterator(size32_t index = 0) const;
00108
00109
00110
00111
00112 virtual ListMuterator::Handle listIterator(size32_t index = 0);
00113
00114
00115
00116
00117 virtual Object::Holder remove(size32_t index);
00118
00119
00120
00121
00122 virtual Object::Holder set(size32_t index, Object::Holder oh);
00123
00124
00125
00126
00127 virtual List::View subList(size32_t fromIndex, size32_t toIndex) const;
00128
00129
00130
00131
00132 virtual List::Handle subList(size32_t fromIndex, size32_t toIndex);
00133
00134
00135
00136
00137 public:
00138
00139
00140
00141 virtual size32_t size() const;
00142
00143
00144
00145
00146 virtual Iterator::Handle iterator() const;
00147
00148
00149
00150
00151 virtual Muterator::Handle iterator();
00152
00153
00154
00155
00156 virtual bool add(Object::Holder oh);
00157
00158
00159
00160
00161 virtual bool addAll(Collection::View vc);
00162
00163
00164
00165
00166 virtual bool remove(Object::View v);
00167
00168
00169
00170
00171 virtual bool removeAll(Collection::View vColl);
00172
00173
00174
00175
00176 virtual bool retainAll(Collection::View vCol);
00177
00178
00179
00180
00181 virtual void clear();
00182
00183
00184
00185
00186 protected:
00187
00188
00189
00190 virtual void onEscape(bool fEscaped) const;
00191
00192
00193
00194
00195 public:
00196
00197
00198
00199 class ListElement
00200 : public class_spec<ListElement>
00201 {
00202 friend class factory<ListElement>;
00203
00204
00205
00206 protected:
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 ListElement(ListElement::Handle hNext,
00218 ListElement::Handle hPrev, Object::Holder hObj);
00219
00220
00221
00222
00223 public:
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 template<class T> static TypedHandle<T>
00238 nextElement(const TypedHandle<T>& thElement, size32_t c);
00239
00240
00241 public:
00242
00243
00244
00245 virtual size64_t sizeOf(bool fDeep = false) const;
00246
00247
00248
00249 public:
00250
00251
00252
00253 mutable MemberHandle<ListElement> next;
00254
00255
00256
00257
00258 MemberHandle<ListElement> previous;
00259
00260
00261
00262
00263 MemberHolder<Object> value;
00264 };
00265
00266
00267
00268
00269 public:
00270
00271
00272
00273
00274
00275 class SubLinkedList
00276 : public class_spec<SubLinkedList,
00277 extends<SubList> >
00278 {
00279 friend class factory<SubLinkedList>;
00280
00281
00282
00283 protected:
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 SubLinkedList(size32_t fromIndex, size32_t toIndex,
00296 List::Holder ohList);
00297
00298
00299
00300
00301 public:
00302
00303
00304
00305 virtual bool retainAll(Collection::View vColl);
00306
00307
00308
00309
00310 virtual void clear();
00311
00312
00313
00314
00315 virtual List::View
00316 subList(size32_t fromIndex, size32_t toIndex) const;
00317
00318
00319
00320
00321 virtual List::Handle
00322 subList(size32_t fromIndex, size32_t toIndex);
00323 };
00324
00325
00326
00327
00328 protected:
00329
00330
00331
00332
00333
00334
00335
00336 virtual void assertIndex(size32_t i) const;
00337
00338 private:
00339
00340
00341
00342
00343
00344 Object::Holder removeElement(ListElement::Handle hElement,
00345 size32_t index);
00346
00347
00348
00349
00350
00351
00352
00353 void addElement(ListElement::Handle hNext, Object::Holder oh);
00354
00355
00356
00357 protected:
00358
00359
00360
00361 size32_t m_cElements;
00362
00363
00364
00365
00366 mutable MemberHandle<ListElement> m_hHead;
00367
00368
00369
00370
00371 mutable MemberHandle<ListElement> m_hTail;
00372
00373
00374
00375
00376 friend class SubLinkedList;
00377 friend class LinkedListIterator;
00378 };
00379
00380 COH_CLOSE_NAMESPACE2
00381
00382 #endif // COH_LINKED_LIST_HPP