version 1.22, 2002/08/27 23:38:44
|
version 1.22.2.1, 2002/10/28 15:43:20
|
|
|
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
PEGASUS_ARRAY_T& Array<PEGASUS_ARRAY_T>::operator[](Uint32 index) |
PEGASUS_ARRAY_T& Array<PEGASUS_ARRAY_T>::operator[](Uint32 pos) |
{ | { |
if (index >= size()) |
if (pos >= size()) |
throw IndexOutOfBoundsException(); |
throw OutOfBounds(); |
| |
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data()[index]; |
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data()[pos]; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
const PEGASUS_ARRAY_T& Array<PEGASUS_ARRAY_T>::operator[](Uint32 index) const |
const PEGASUS_ARRAY_T& Array<PEGASUS_ARRAY_T>::operator[](Uint32 pos) const |
{ | { |
if (index >= size()) |
if (pos >= size()) |
throw IndexOutOfBoundsException(); |
throw OutOfBounds(); |
| |
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data()[index]; |
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data()[pos]; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
|
|
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 index, const PEGASUS_ARRAY_T& x) |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T& x) |
{ | { |
insert(index, &x, 1); |
insert(pos, &x, 1); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 index, const PEGASUS_ARRAY_T* x, Uint32 size) |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T* x, Uint32 size) |
{ | { |
if (index > this->size()) |
if (pos > this->size()) |
throw IndexOutOfBoundsException(); |
throw OutOfBounds(); |
| |
reserveCapacity(this->size() + size); | reserveCapacity(this->size() + size); |
| |
Uint32 n = this->size() - index; |
Uint32 n = this->size() - pos; |
| |
if (n) | if (n) |
memmove(_data() + index + size, |
memmove( |
_data() + index, |
_data() + pos + size, _data() + pos, sizeof(PEGASUS_ARRAY_T) * n); |
sizeof(PEGASUS_ARRAY_T) * n); |
|
| |
CopyToRaw(_data() + index, x, size); |
CopyToRaw(_data() + pos, x, size); |
static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->size += size; | static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->size += size; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 index) |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos) |
{ | { |
remove(index, 1); |
remove(pos, 1); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 index, Uint32 size) |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos, Uint32 size) |
{ | { |
if (index + size - 1 > this->size()) |
if (pos + size - 1 > this->size()) |
throw IndexOutOfBoundsException(); |
throw OutOfBounds(); |
| |
Destroy(_data() + index, size); |
Destroy(_data() + pos, size); |
| |
Uint32 rem = this->size() - (index + size); |
Uint32 rem = this->size() - (pos + size); |
| |
if (rem) | if (rem) |
memmove(_data() + index, |
memmove( |
_data() + index + size, |
_data() + pos, _data() + pos + size, sizeof(PEGASUS_ARRAY_T) * rem); |
sizeof(PEGASUS_ARRAY_T) * rem); |
|
| |
static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->size -= size; | static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->size -= size; |
} | } |
|
|
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#endif | #endif |
|
PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::begin() |
|
{ |
|
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data(); |
|
} |
|
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
|
#endif |
|
PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::end() |
|
{ |
|
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data() + size(); |
|
} |
|
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
|
#endif |
|
const PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::begin() const |
|
{ |
|
return getData(); |
|
} |
|
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
|
#endif |
|
const PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::end() const |
|
{ |
|
return getData() + size(); |
|
} |
|
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
|
#endif |
PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::_data() const | PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::_data() const |
{ | { |
return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data(); | return static_cast<ArrayRep<PEGASUS_ARRAY_T>*>(_rep)->data(); |