38#include <dime/Basic.h>
59#pragma warning(disable:4251)
60#pragma warning(disable:4275)
71 void append(
const T &value);
74 void insertElem(
const int idx,
const T &value);
75 void setElem(
const int index,
const T &value);
76 T getElem(
const int index)
const;
77 void getElem(
const int index, T &elem)
const;
78 T getLastElem()
const;
79 void getLastElem(T &elem)
const;
80 T &operator [](
const int index);
81 T operator [](
const int index)
const;
102template <
class T>
inline
105 this->array =
new T[size];
110template <
class T>
inline
113 delete [] this->array;
116template <
class T>
inline void
119 int oldsize = this->size;
120 T *oldarray = this->array;
122 this->array =
new T[this->size];
123 for (
int i = 0; i < oldsize; i++) this->array[i] = oldarray[i];
127template <
class T>
inline void
130 if (this->num >= this->size) growArray();
131 this->array[this->num++] = elem;
135template <
class T>
inline void
138 while (this->size <= this->num+array.
count()) growArray();
139 for (
int i=0;i<array.
count();i++)
140 this->array[this->num++] = array[i];
143template <
class T>
inline void
146 int newsize=this->num+array.
count();
148 if (this->size<=newsize) {
149 T *oldarray=this->array;
150 this->array=
new T[newsize];
152 for (i=0;i<array.
count(); i++) this->array[i] = array[i];
153 for (i=0;i<this->num;i++) this->array[i+array.
count()] = oldarray[i];
157 for (i=0;i<this->num;i++) this->array[array.
count()+i]=this->array[i];
158 for (i=0;i<array.
count();i++) this->array[i] = array[i];
160 this->num+=array.
count();
163template <
class T>
inline void
169 for (
int i = n; i > idx; i--) {
170 this->array[i] = this->array[i-1];
172 this->array[idx] = elem;
176template <
class T>
inline void
179 while (index >= this->size) growArray();
180 if (this->num <= index) this->num = index+1;
181 this->array[index] = elem;
184template <
class T>
inline T
187 return this->array[index];
190template <
class T>
inline void
193 elem = this->array[index];
196template <
class T>
inline T
199 return this->array[this->num-1];
202template <
class T>
inline void
205 elem = this->array[this->num-1];
208template <
class T>
inline T &
211 while (index >= this->size) growArray();
212 if (this->num <= index) this->num = index + 1;
213 return this->array[index];
216template <
class T>
inline T
219 return this->array[index];
222template <
class T>
inline void
225 if (this->num <= 0 || index >= this->num)
return;
226 for (
int i = index; i < this->num-1; i++)
227 this->array[i] = this->array[i+1];
231template <
class T>
inline void
234 this->array[index] = this->array[--this->num];
237template <
class T>
inline void
241 for (
int i=0;i<this->num/2;i++) {
243 this->array[i]=this->array[this->num-1-i];
244 this->array[this->num-1-i]=tmp;
248template <
class T>
inline void
251 if (count < this->num)
255template <
class T>
inline int
261template <
class T>
inline int
267template <
class T>
inline T *
273template <
class T>
inline const T *
279template <
class T>
inline void
282 delete [] this->array;
283 this->array =
new T[initsize];
284 this->size = initsize;
288template <
class T>
inline void
291 delete [] this->array;
297template <
class T>
inline void
300 T *oldarray = this->array;
301 this->array =
new T[this->num];
302 for (
int i = 0; i < this->num; i++) this->array[i] = oldarray[i];
303 this->size = this->num;
The dimeArray class is internal / private.
Definition: Array.h:66
void makeEmpty(const int initsize=4)
Definition: Array.h:280
void removeElemFast(const int index)
Definition: Array.h:232
int count() const
Definition: Array.h:256
void freeMemory()
Definition: Array.h:289
void setCount(const int count)
Definition: Array.h:249
int allocSize() const
Definition: Array.h:262
void removeElem(const int index)
Definition: Array.h:223
const T * constArrayPointer() const
Definition: Array.h:274
T * arrayPointer()
Definition: Array.h:268
void shrinkToFit()
Definition: Array.h:298