34 #if !defined(AS_NO_MEMORY_H) 40 #pragma warning(disable:4345) // warning about a change in how the code is handled in this version 43 #include "as_config.h" 54 void Allocate(asUINT numElements,
bool keepData);
55 void AllocateNoConstruct(asUINT numElements,
bool keepData);
56 asUINT GetCapacity()
const;
58 void PushLast(
const T &element);
61 bool SetLength(asUINT numElements);
62 bool SetLengthNoConstruct(asUINT numElements);
63 asUINT GetLength()
const;
65 void Copy(
const T *, asUINT count);
69 const T &operator [](asUINT index)
const;
70 T &operator [](asUINT index);
72 const T *AddressOf()
const;
75 void Concatenate(T *,
unsigned int count);
77 bool Exists(
const T &element)
const;
78 int IndexOf(
const T &element)
const;
79 void RemoveIndex(asUINT index);
80 void RemoveValue(
const T &element);
81 void RemoveIndexUnordered(asUINT index);
90 char buf[2 * 4 * AS_PTR_SIZE];
127 Allocate(reserve,
false);
143 asASSERT(index < length);
150 asASSERT(index < length);
157 if (length == maxLength) {
161 Allocate(2 * maxLength,
true);
163 if (length == maxLength) {
169 array[length++] = element;
174 asASSERT(length > 0);
176 return array[--length];
189 if (
sizeof(T)*numElements <=
sizeof(buf))
191 tmp =
reinterpret_cast<T *
>(buf);
194 tmp = asNEWARRAY(T, numElements);
203 for (asUINT n = length; n < numElements; n++)
207 for (asUINT n = 0; n < numElements; n++)
213 asUINT oldLength = length;
217 if (length > numElements)
218 length = numElements;
223 for (asUINT n = length; n < oldLength; n++)
227 if (length > numElements)
228 length = numElements;
230 for (asUINT n = 0; n < length; n++)
236 for (asUINT n = 0; n < oldLength; n++)
239 if (array != reinterpret_cast<T *>(buf))
240 asDELETEARRAY(array);
245 maxLength = numElements;
258 if (
sizeof(T)*numElements <=
sizeof(buf))
260 tmp =
reinterpret_cast<T *
>(buf);
263 tmp = asNEWARRAY(T, numElements);
274 if (length > numElements)
275 length = numElements;
280 if (length > numElements)
281 length = numElements;
283 memcpy(tmp, array,
sizeof(T)*length);
287 if (array != reinterpret_cast<T *>(buf))
288 asDELETEARRAY(array);
293 maxLength = numElements;
303 if (numElements > maxLength) {
304 Allocate(numElements,
true);
305 if (numElements > maxLength) {
311 length = numElements;
317 if (numElements > maxLength) {
318 AllocateNoConstruct(numElements,
true);
319 if (numElements > maxLength) {
325 length = numElements;
331 if (maxLength < count) {
332 Allocate(count,
false);
333 if (maxLength < count) {
339 for (asUINT n = 0; n < count; n++)
347 Copy(copy.array, copy.length);
355 asUINT tmpLength = length;
356 asUINT tmpMaxLength = maxLength;
357 char tmpBuf[
sizeof(buf)];
358 memcpy(tmpBuf, buf,
sizeof(buf));
361 length = other.length;
362 maxLength = other.maxLength;
363 memcpy(buf, other.buf,
sizeof(buf));
365 other.array = tmpArray;
366 other.length = tmpLength;
367 other.maxLength = tmpMaxLength;
368 memcpy(other.buf, tmpBuf,
sizeof(buf));
371 if (array == reinterpret_cast<T *>(other.buf))
372 array =
reinterpret_cast<T *
>(buf);
373 if (other.array == reinterpret_cast<T *>(buf))
374 other.array = reinterpret_cast<T *>(other.buf);
379 if (length != other.length)
return false;
381 for (asUINT n = 0; n < length; n++)
382 if (array[n] != other.array[n])
390 return !(*
this == other);
397 if (maxLength < length + other.length) {
398 Allocate(length + other.length,
true);
399 if (maxLength < length + other.length) {
405 for (asUINT n = 0; n < other.length; n++)
406 array[length + n] = other.array[n];
408 length += other.length;
416 for (
unsigned int c = 0; c < count; c++)
422 return IndexOf(e) == -1 ? false :
true;
427 for (asUINT n = 0; n < length; n++)
428 if (array[n] == e)
return static_cast<int>(n);
435 if (index < length) {
436 for (asUINT n = index; n < length - 1; n++)
437 array[n] = array[n + 1];
445 for (asUINT n = 0; n < length; n++) {
455 if (index == length - 1)
457 else if (index < length)
458 array[index] = PopLast();
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: as_array.h:47