Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLCORE_CONTAINER_FASTPOOL_H__
00024 #define __PLCORE_CONTAINER_FASTPOOL_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include "PLCore/Container/Container.h"
00032
00033
00034
00035
00036
00037 namespace PLCore {
00038
00039
00040
00041
00042
00043 template<class ValueType> class FastPool;
00044 template<class ValueType> class FastPoolIterator;
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 template <class ValueType>
00055 class FastPoolElement {
00056
00057
00058
00059
00060
00061 friend class FastPool<ValueType>;
00062 friend class FastPoolIterator<ValueType>;
00063
00064
00065
00066
00067
00068 public:
00069
00070
00071
00072
00073 FastPoolElement();
00074
00075
00076
00077
00078
00079 virtual ~FastPoolElement();
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 virtual FastPoolElement<ValueType> &operator =(const FastPoolElement<ValueType> &lstSource);
00092
00093
00094
00095
00096
00097 private:
00098 ValueType *m_pNextElement;
00099 ValueType *m_pPreviousElement;
00100
00101
00102 };
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 template <class ValueType>
00118 class FastPool : public Container<ValueType> {
00119
00120
00121
00122
00123
00124 friend class FastPoolIterator<ValueType>;
00125
00126
00127
00128
00129
00130 public:
00131
00132
00133
00134
00135 FastPool();
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 FastPool(const FastPool<ValueType> &lstSource, uint32 nStart = 0, uint32 nCount = 0);
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 FastPool(const Container<ValueType> &lstSource, uint32 nStart = 0, uint32 nCount = 0);
00162
00163
00164
00165
00166
00167 virtual ~FastPool();
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179 Container<ValueType> &operator =(const FastPool<ValueType> &lstSource);
00180
00181
00182
00183
00184
00185
00186
00187
00188 uint32 GetNumOfFreeElements() const;
00189
00190
00191
00192
00193
00194
00195
00196
00197 uint32 GetFreeSize() const;
00198
00199
00200
00201
00202
00203
00204
00205
00206 void FreeElements();
00207
00208
00209
00210
00211
00212 void RemoveAllFreeElements();
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 void RemoveElement(ValueType &cElement);
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 int GetElementIndex(ValueType &cElement) const;
00238
00239
00240
00241
00242
00243 private:
00244
00245
00246
00247
00248
00249
00250
00251 ValueType &AddElement();
00252
00253
00254
00255
00256
00257 private:
00258
00259 uint32 m_nNumOfElements;
00260 ValueType *m_pFirstElement;
00261 ValueType *m_pLastElement;
00262
00263 uint32 m_nNumOfFreeElements;
00264 ValueType *m_pFirstFreeElement;
00265
00266
00267
00268
00269
00270 public:
00271 virtual Iterator<ValueType> GetIterator(uint32 nIndex = 0) const override;
00272 virtual ConstIterator<ValueType> GetConstIterator(uint32 nIndex = 0) const override;
00273 virtual Iterator<ValueType> GetEndIterator() const override;
00274 virtual ConstIterator<ValueType> GetConstEndIterator() const override;
00275
00276
00277
00278
00279
00280 public:
00281 virtual bool IsEmpty() const override;
00282 virtual uint32 GetNumOfElements() const override;
00283 virtual uint32 GetElementSize() const override;
00284 virtual uint32 GetSize() const override;
00285 virtual void Clear() override;
00286 virtual bool IsElement(const ValueType &Element) const override;
00287 virtual int GetIndex(const ValueType &Element) const override;
00288 virtual ValueType &Get(uint32 nIndex) const override;
00289 virtual ValueType &operator [](uint32 nIndex) const override;
00290 virtual bool Replace(const ValueType &Element1, const ValueType &Element2) override;
00291 virtual bool ReplaceAtIndex(uint32 nIndex, const ValueType &Element) override;
00292 virtual ValueType &Add() override;
00293 virtual ValueType &Add(const ValueType &Element) override;
00294 virtual uint32 Add(const ValueType *pElements, uint32 nCount) override;
00295 virtual Container<ValueType> &operator +=(const ValueType &Element) override;
00296 virtual bool Add(const Container<ValueType> &lstContainer, uint32 nStart = 0, uint32 nCount = 0) override;
00297 virtual Container<ValueType> &operator +=(const Container<ValueType> &lstContainer) override;
00298 virtual ValueType &AddAtIndex(int nIndex) override;
00299 virtual ValueType &AddAtIndex(const ValueType &Element, int nIndex) override;
00300 virtual bool Remove(const ValueType &Element) override;
00301 virtual bool RemoveAtIndex(uint32 nElement) override;
00302 virtual Container<ValueType> &operator -=(const ValueType &Element) override;
00303 virtual bool Remove(const Container<ValueType> &lstContainer, uint32 nStart = 0, uint32 nCount = 0) override;
00304 virtual Container<ValueType> &operator -=(const Container<ValueType> &lstContainer) override;
00305 virtual bool Copy(const Container<ValueType> &lstContainer, uint32 nStart = 0, uint32 nCount = 0) override;
00306 virtual Container<ValueType> &operator =(const Container<ValueType> &lstContainer) override;
00307 virtual bool Compare(const Container<ValueType> &lstContainer, uint32 nStart = 0, uint32 nCount = 0) const override;
00308 virtual bool operator ==(const Container<ValueType> &lstContainer) const override;
00309 virtual bool operator !=(const Container<ValueType> &lstContainer) const override;
00310
00311
00312 };
00313
00314
00315
00316
00317
00318 }
00319
00320
00321
00322
00323
00324 #include "PLCore/Container/FastPool.inl"
00325
00326
00327 #endif // __PLCORE_CONTAINER_FASTPOOL_H__