version 1.27, 2005/11/03 02:56:11
|
version 1.28, 2005/11/03 03:19:28
|
|
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array(Uint32 size) | Array<PEGASUS_ARRAY_T>::Array(Uint32 size) |
{ | { |
Array_rep = ArrayRep<PEGASUS_ARRAY_T>::alloc(size); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::alloc(size); |
| |
if (!_rep) | if (!_rep) |
throw NullPointer(); | throw NullPointer(); |
|
|
if (x._rep != Array_rep) | if (x._rep != Array_rep) |
{ | { |
ArrayRep<PEGASUS_ARRAY_T>::unref(Array_rep); | ArrayRep<PEGASUS_ARRAY_T>::unref(Array_rep); |
ArrayRep<PEGASUS_ARRAY_T>::ref(Array_rep = x._rep); |
_rep = x._rep; |
|
ArrayRep<PEGASUS_ARRAY_T>::ref(Array_rep); |
} | } |
| |
return *this; | return *this; |
|
|
void Array<PEGASUS_ARRAY_T>::swap(Array<PEGASUS_ARRAY_T>& x) | void Array<PEGASUS_ARRAY_T>::swap(Array<PEGASUS_ARRAY_T>& x) |
{ | { |
ArrayRep<PEGASUS_ARRAY_T>* tmp = Array_rep; | ArrayRep<PEGASUS_ARRAY_T>* tmp = Array_rep; |
Array_rep = x._rep; |
_rep = x._rep; |
x._rep = tmp; | x._rep = tmp; |
} | } |
| |
|
|
void Array<PEGASUS_ARRAY_T>::remove(Uint32 index, Uint32 size) | void Array<PEGASUS_ARRAY_T>::remove(Uint32 index, Uint32 size) |
{ | { |
if (Array_refs.get() != 1) | if (Array_refs.get() != 1) |
Array_rep = ArrayRep<PEGASUS_ARRAY_T>::copy_on_write(Array_rep); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::copy_on_write(Array_rep); |
| |
// Case 1: attempting to remove last element (this is an optimization | // Case 1: attempting to remove last element (this is an optimization |
// for when the array is used as a stack; see Stack class). | // for when the array is used as a stack; see Stack class). |
|
|
#endif | #endif |
| |
if (Array_refs.get() != 1) | if (Array_refs.get() != 1) |
Array_rep = ArrayRep<PEGASUS_ARRAY_T>::copy_on_write(Array_rep); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::copy_on_write(Array_rep); |
| |
return Array_data[index]; | return Array_data[index]; |
} | } |