35 #include <dime/Basic.h>
55 #ifdef _MSC_VER // Microsoft Visual C++
56 #pragma warning(disable:4251)
57 #pragma warning(disable:4275)
68 void append(
const T &value);
71 void insertElem(
const int idx,
const T &value);
72 void setElem(
const int index,
const T &value);
73 T getElem(
const int index)
const;
74 void getElem(
const int index, T &elem)
const;
75 T getLastElem()
const;
76 void getLastElem(T &elem)
const;
77 T &operator [](
const int index);
78 T operator [](
const int index)
const;
99 template <
class T>
inline
102 this->array =
new T[size];
107 template <
class T>
inline
110 delete [] this->array;
113 template <
class T>
inline void
116 int oldsize = this->size;
117 T *oldarray = this->array;
119 this->array =
new T[this->size];
120 for (
int i = 0; i < oldsize; i++) this->array[i] = oldarray[i];
124 template <
class T>
inline void
127 if (this->num >= this->size) growArray();
128 this->array[this->num++] = elem;
132 template <
class T>
inline void
135 while (this->size <= this->num+array.
count()) growArray();
136 for (
int i=0;i<array.
count();i++)
137 this->array[this->num++] = array[i];
140 template <
class T>
inline void
143 int newsize=this->num+array.
count();
145 if (this->size<=newsize) {
146 T *oldarray=this->array;
147 this->array=
new T[newsize];
149 for (i=0;i<array.
count(); i++) this->array[i] = array[i];
150 for (i=0;i<this->num;i++) this->array[i+array.
count()] = oldarray[i];
154 for (i=0;i<this->num;i++) this->array[array.
count()+i]=this->array[i];
155 for (i=0;i<array.
count();i++) this->array[i] = array[i];
157 this->num+=array.
count();
160 template <
class T>
inline void
166 for (
int i = n; i > idx; i--) {
167 this->array[i] = this->array[i-1];
169 this->array[idx] = elem;
173 template <
class T>
inline void
176 while (index >= this->size) growArray();
177 if (this->num <= index) this->num = index+1;
178 this->array[index] = elem;
181 template <
class T>
inline T
184 return this->array[index];
187 template <
class T>
inline void
190 elem = this->array[index];
193 template <
class T>
inline T
196 return this->array[this->num-1];
199 template <
class T>
inline void
202 elem = this->array[this->num-1];
205 template <
class T>
inline T &
208 while (index >= this->size) growArray();
209 if (this->num <= index) this->num = index + 1;
210 return this->array[index];
213 template <
class T>
inline T
216 return this->array[index];
219 template <
class T>
inline void
222 if (this->num <= 0 || index >= this->num)
return;
223 for (
int i = index; i < this->num-1; i++)
224 this->array[i] = this->array[i+1];
228 template <
class T>
inline void
231 this->array[index] = this->array[--this->num];
234 template <
class T>
inline void
238 for (
int i=0;i<this->num/2;i++) {
240 this->array[i]=this->array[this->num-1-i];
241 this->array[this->num-1-i]=tmp;
245 template <
class T>
inline void
248 if (count < this->num)
252 template <
class T>
inline int
258 template <
class T>
inline int
264 template <
class T>
inline T *
270 template <
class T>
inline const T *
276 template <
class T>
inline void
279 delete [] this->array;
280 this->array =
new T[initsize];
281 this->size = initsize;
285 template <
class T>
inline void
288 delete [] this->array;
294 template <
class T>
inline void
297 T *oldarray = this->array;
298 this->array =
new T[this->num];
299 for (
int i = 0; i < this->num; i++) this->array[i] = oldarray[i];
300 this->size = this->num;
304 #endif // ! DIME_ARRAY_H