1 #ifndef __FLEXARRAY_H__ 2 #define __FLEXARRAY_H__ 15 , CurrentCapacity(DefaultCapacity)
17 pArray =
new T[DefaultCapacity];
23 CurrentSize = Arg.CurrentSize;
24 CurrentCapacity = Arg.CurrentCapacity;
25 pArray =
new T[CurrentCapacity];
26 for (
int i = 0; i < CurrentSize; i++)
41 if (CurrentSize + 1 > CurrentCapacity)
46 pArray[CurrentSize] = NewItem;
53 if (CurrentSize + 1 > CurrentCapacity)
58 for (
int i = CurrentSize; i > Index; i--)
60 pArray[i] = pArray[i - 1];
62 pArray[Index] = NewItem;
69 CurrentCapacity = Capacity;
70 T *pTmp =
new T[Capacity];
71 if (CurrentSize > Capacity)
73 CurrentSize = Capacity;
75 for (
int i = 0; i < CurrentSize; i++)
89 for (
int i = 0; i < CurrentSize; i++)
91 if (Item == pArray[i])
93 for (
int j = i; j < CurrentSize - 1; j++)
95 pArray[j] = pArray[j + 1];
106 return pArray[Index];
146 if (CurrentSize > CurrentCapacity)
148 Reallocate(CurrentSize);
151 for (
int i = 0; i < CurrentSize; i++)
153 pArray[i].Serialize(pStream);
158 #endif // #ifndef __FLEXARRAY_H__ FlexArray(const FlexArray &Arg)
Definition: FlexArray.h:21
void PushBack(T NewItem)
Definition: FlexArray.h:39
~FlexArray()
Definition: FlexArray.h:33
virtual bool Serialize(s32 *pValue)=0
FlexArray(int DefaultCapacity=20)
Definition: FlexArray.h:13
void Serialize(MemoryStreamInterface *pStream)
Definition: FlexArray.h:143
void Remove(T Item)
Definition: FlexArray.h:87
void Insert(T NewItem, int Index)
Definition: FlexArray.h:51
Definition: FlexArray.h:7
Definition: MemoryStreamInterface.h:8
T operator[](int Index) const
Definition: FlexArray.h:104
int GetCurrentSize() const
Definition: FlexArray.h:84
void Reallocate(int Capacity)
Definition: FlexArray.h:67