version 1.10, 2002/05/17 02:35:51
|
version 1.12, 2002/05/17 22:33:30
|
|
|
#else | #else |
PEGASUS_TEMPLATE_SPECIALIZATION | PEGASUS_TEMPLATE_SPECIALIZATION |
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array(ArrayRep<PEGASUS_ARRAY_T>* rep) |
|
{ |
|
_rep = rep->clone(); |
|
} |
|
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
|
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif |
|
Array<PEGASUS_ARRAY_T>::~Array() | Array<PEGASUS_ARRAY_T>::~Array() |
{ | { |
Rep::destroy(_rep); | Rep::destroy(_rep); |
|
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::prepend(const PEGASUS_ARRAY_T& x) | void Array<PEGASUS_ARRAY_T>::prepend(const PEGASUS_ARRAY_T& x) |
{ | { |
reserve(size() + 1); |
prepend(&x, 1); |
memmove(_data() + 1, _data(), sizeof(PEGASUS_ARRAY_T) * size()); |
|
new(_data()) PEGASUS_ARRAY_T(x); |
|
_rep->size++; |
|
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
|
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T& x) | void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T& x) |
{ | { |
if (pos > size()) |
insert(pos, &x, 1); |
ThrowOutOfBounds(); |
|
|
|
reserve(size() + 1); |
|
|
|
Uint32 n = size() - pos; |
|
|
|
if (n) |
|
memmove(_data() + pos + 1, _data() + pos, sizeof(PEGASUS_ARRAY_T) * n); |
|
|
|
new(_data() + pos) PEGASUS_ARRAY_T(x); |
|
_rep->size++; |
|
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
|
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T* x, Uint32 size) | void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T* x, Uint32 size) |
{ | { |
if (pos + size > this->size()) |
if (pos > this->size()) |
ThrowOutOfBounds(); | ThrowOutOfBounds(); |
| |
reserve(this->size() + size); | reserve(this->size() + size); |
|
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos) | void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos) |
{ | { |
if (pos >= this->size()) |
remove(pos, 1); |
ThrowOutOfBounds(); |
|
|
|
#if defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
|
Destroy<PEGASUS_ARRAY_T>(_data() + pos); |
|
#else |
|
Destroy(_data() + pos); |
|
#endif |
|
|
|
Uint32 rem = this->size() - pos - 1; |
|
|
|
if (rem) |
|
memmove(_data() + pos, _data() + pos + 1, sizeof(PEGASUS_ARRAY_T) * rem); |
|
|
|
_rep->size--; |
|
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
|
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos, Uint32 size) | void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos, Uint32 size) |
{ | { |
if (pos + size > this->size()) |
if (pos + size - 1 > this->size()) |
ThrowOutOfBounds(); | ThrowOutOfBounds(); |
| |
#if defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) | #if defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |