version 1.7, 2002/05/04 02:54:38
|
version 1.36, 2008/12/02 09:00:33
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%LICENSE//////////////////////////////////////////////////////////////// |
// |
|
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
|
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy |
// Licensed to The Open Group (TOG) under one or more contributor license |
// of this software and associated documentation files (the "Software"), to |
// agreements. Refer to the OpenPegasusNOTICE.txt file distributed with |
// deal in the Software without restriction, including without limitation the |
// this work for additional information regarding copyright ownership. |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
// Each contributor licenses this file to you under the OpenPegasus Open |
// sell copies of the Software, and to permit persons to whom the Software is |
// Source License; you may not use this file except in compliance with the |
// furnished to do so, subject to the following conditions: |
// License. |
// | // |
// THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN |
// Permission is hereby granted, free of charge, to any person obtaining a |
// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED |
// copy of this software and associated documentation files (the "Software"), |
// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
// to deal in the Software without restriction, including without limitation |
// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
// the rights to use, copy, modify, merge, publish, distribute, sublicense, |
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
// and/or sell copies of the Software, and to permit persons to whom the |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
// Software is furnished to do so, subject to the following conditions: |
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
// | // |
//============================================================================== |
// The above copyright notice and this permission notice shall be included |
|
// in all copies or substantial portions of the Software. |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
// | // |
// Modified By: |
////////////////////////////////////////////////////////////////////////// |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#if defined(PEGASUS_EXPLICIT_INSTANTIATION) || !defined(PEGASUS_ARRAY_T) |
// Only include if not included as general template or if explicit instantiation |
|
#if !defined(Pegasus_ArrayImpl_h) || defined(PEGASUS_ARRAY_T) |
|
#if !defined(PEGASUS_ARRAY_T) |
|
#define Pegasus_ArrayImpl_h |
|
#endif |
|
|
|
PEGASUS_NAMESPACE_END |
|
|
|
#include <Pegasus/Common/Memory.h> |
|
#include <Pegasus/Common/ArrayRep.h> |
|
#include <Pegasus/Common/InternalException.h> |
|
#include <Pegasus/Common/Linkage.h> |
|
|
|
PEGASUS_NAMESPACE_BEGIN |
|
|
|
PEGASUS_COMMON_LINKAGE void ArrayThrowIndexOutOfBoundsException(); |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array() | Array<PEGASUS_ARRAY_T>::Array() |
{ | { |
_rep = Rep::getNullRep(); |
_rep = &ArrayRepBase::_empty_rep; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array(const Array<PEGASUS_ARRAY_T>& x) | Array<PEGASUS_ARRAY_T>::Array(const Array<PEGASUS_ARRAY_T>& x) |
{ | { |
Rep::inc(_rep = x._rep); |
_rep = x._rep; |
|
ArrayRep<PEGASUS_ARRAY_T>::ref(Array_rep); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array(Uint32 size) | Array<PEGASUS_ARRAY_T>::Array(Uint32 size) |
{ | { |
_rep = Rep::create(size); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::alloc(size); |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
|
InitializeRaw<PEGASUS_ARRAY_T>(_rep->data(), size); |
// ArrayRep<PEGASUS_ARRAY_T>::alloc() throws a bad_alloc exception if |
#else |
// storage could not be obtained. |
InitializeRaw(_rep->data(), size); |
|
#endif |
InitializeRaw(Array_data, size); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array(Uint32 size, const PEGASUS_ARRAY_T& x) | Array<PEGASUS_ARRAY_T>::Array(Uint32 size, const PEGASUS_ARRAY_T& x) |
{ | { |
_rep = Rep::create(size); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::alloc(size); |
| |
PEGASUS_ARRAY_T* data = _rep->data(); |
// ArrayRep<PEGASUS_ARRAY_T>::alloc() throws a bad_alloc exception if |
|
// storage could not be obtained. |
|
|
|
PEGASUS_ARRAY_T* data = Array_data; |
|
|
|
// Note: we could use template specialization (by adding functions to |
|
// Memory.h) so that this loop becomes a memset() for single byte raw |
|
// types, but this function is rarely called. |
| |
while (size--) | while (size--) |
new(data++) PEGASUS_ARRAY_T(x); | new(data++) PEGASUS_ARRAY_T(x); |
|
|
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::Array(const PEGASUS_ARRAY_T* items, Uint32 size) | Array<PEGASUS_ARRAY_T>::Array(const PEGASUS_ARRAY_T* items, Uint32 size) |
{ | { |
_rep = Rep::create(size); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::alloc(size); |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
|
CopyToRaw<PEGASUS_ARRAY_T>(_rep->data(), items, size); |
// ArrayRep<PEGASUS_ARRAY_T>::alloc() throws a bad_alloc exception if |
#else |
// storage could not be obtained. |
CopyToRaw(_rep->data(), items, size); |
|
#endif |
CopyToRaw(Array_data, items, size); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>::~Array() | Array<PEGASUS_ARRAY_T>::~Array() |
{ | { |
Rep::dec(_rep); |
ArrayRep<PEGASUS_ARRAY_T>::unref(Array_rep); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
Array<PEGASUS_ARRAY_T>& Array<PEGASUS_ARRAY_T>::operator=( | Array<PEGASUS_ARRAY_T>& Array<PEGASUS_ARRAY_T>::operator=( |
const Array<PEGASUS_ARRAY_T>& x) | const Array<PEGASUS_ARRAY_T>& x) |
{ | { |
if (x._rep != _rep) |
if (x._rep != Array_rep) |
{ | { |
Rep::dec(_rep); |
ArrayRep<PEGASUS_ARRAY_T>::unref(Array_rep); |
Rep::inc(_rep = x._rep); |
_rep = x._rep; |
|
ArrayRep<PEGASUS_ARRAY_T>::ref(Array_rep); |
} | } |
|
|
return *this; | return *this; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::clear() | void Array<PEGASUS_ARRAY_T>::clear() |
{ | { |
Rep::dec(_rep); |
if (Array_size) |
_rep = Rep::getNullRep(); |
{ |
|
if (Array_refs.get() == 1) |
|
{ |
|
Destroy(Array_data, Array_size); |
|
Array_size = 0; |
} | } |
|
else |
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
|
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif |
|
void Array<PEGASUS_ARRAY_T>::_reserveAux(Uint32 capacity) |
|
{ | { |
Uint32 size = this->size(); |
ArrayRep<PEGASUS_ARRAY_T>::unref(Array_rep); |
Rep* rep = Rep::create(capacity); |
_rep = &ArrayRepBase::_empty_rep; |
rep->size = size; |
} |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
} |
CopyToRaw<PEGASUS_ARRAY_T>(rep->data(), _rep->data(), size); |
|
#else |
|
CopyToRaw(rep->data(), _rep->data(), size); |
|
#endif |
|
Rep::dec(_rep); |
|
_rep = rep; |
|
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::_copyOnWriteAux() |
void Array<PEGASUS_ARRAY_T>::reserveCapacity(Uint32 capacity) |
{ | { |
if (_rep->ref != 1) |
if (capacity > Array_capacity || Array_refs.get() != 1) |
{ | { |
Rep* rep = _rep->clone(); |
ArrayRep<PEGASUS_ARRAY_T>* rep = |
Rep::dec(_rep); |
ArrayRep<PEGASUS_ARRAY_T>::alloc(capacity); |
|
|
|
// ArrayRep<PEGASUS_ARRAY_T>::alloc() throws a bad_alloc exception if |
|
// storage could not be obtained. |
|
|
|
rep->size = Array_size; |
|
|
|
if (Array_refs.get() == 1) |
|
{ |
|
memcpy(rep->data(), Array_data, Array_size*sizeof(PEGASUS_ARRAY_T)); |
|
Array_size = 0; |
|
} |
|
else |
|
CopyToRaw(rep->data(), Array_data, Array_size); |
|
|
|
ArrayRep<PEGASUS_ARRAY_T>::unref(Array_rep); |
_rep = rep; | _rep = rep; |
} | } |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::grow(Uint32 size, const PEGASUS_ARRAY_T& x) | void Array<PEGASUS_ARRAY_T>::grow(Uint32 size, const PEGASUS_ARRAY_T& x) |
{ | { |
_copyOnWrite(); |
reserveCapacity(Array_size + size); |
Uint32 oldSize = _rep->size; |
PEGASUS_ARRAY_T* p = Array_data + Array_size; |
reserve(oldSize + size); |
|
|
|
PEGASUS_ARRAY_T* p = _rep->data() + oldSize; |
|
Uint32 n = size; | Uint32 n = size; |
| |
while (n--) | while (n--) |
new(p++) PEGASUS_ARRAY_T(x); | new(p++) PEGASUS_ARRAY_T(x); |
| |
_rep->size += size; |
Array_size += size; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::swap(Array<PEGASUS_ARRAY_T>& x) | void Array<PEGASUS_ARRAY_T>::swap(Array<PEGASUS_ARRAY_T>& x) |
{ | { |
Rep* tmp = _rep; |
ArrayRep<PEGASUS_ARRAY_T>* tmp = Array_rep; |
_rep = x._rep; | _rep = x._rep; |
x._rep = tmp; | x._rep = tmp; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::append(const PEGASUS_ARRAY_T& x) | void Array<PEGASUS_ARRAY_T>::append(const PEGASUS_ARRAY_T& x) |
{ | { |
_copyOnWrite(); |
Uint32 n = Array_size + 1; |
reserve(size() + 1); |
|
new (_data() + size()) PEGASUS_ARRAY_T(x); |
if (n > Array_capacity || Array_refs.get() != 1) |
_rep->size++; |
reserveCapacity(n); |
|
|
|
new (Array_data + Array_size) PEGASUS_ARRAY_T(x); |
|
Array_size++; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::append(const PEGASUS_ARRAY_T* x, Uint32 size) | void Array<PEGASUS_ARRAY_T>::append(const PEGASUS_ARRAY_T* x, Uint32 size) |
{ | { |
_copyOnWrite(); |
Uint32 n = Array_size + size; |
reserve(this->size() + size); |
reserveCapacity(n); |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
CopyToRaw(Array_data + Array_size, x, size); |
CopyToRaw<PEGASUS_ARRAY_T>(_data() + this->size(), x, size); |
Array_size = n; |
#else |
} |
CopyToRaw(_data() + this->size(), x, size); |
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
#endif | #endif |
_rep->size += size; |
void Array<PEGASUS_ARRAY_T>::appendArray(const Array<PEGASUS_ARRAY_T>& x) |
|
{ |
|
append(x.getData(), x.size()); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::prepend(const PEGASUS_ARRAY_T& x) | void Array<PEGASUS_ARRAY_T>::prepend(const PEGASUS_ARRAY_T& x) |
{ | { |
_copyOnWrite(); |
prepend(&x, 1); |
reserve(size() + 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 |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::prepend(const PEGASUS_ARRAY_T* x, Uint32 size) | void Array<PEGASUS_ARRAY_T>::prepend(const PEGASUS_ARRAY_T* x, Uint32 size) |
{ | { |
_copyOnWrite(); |
reserveCapacity(Array_size + size); |
reserve(this->size() + size); |
memmove( |
memmove(_data() + size, _data(), sizeof(PEGASUS_ARRAY_T) * this->size()); |
Array_data + size, |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
Array_data, |
CopyToRaw<PEGASUS_ARRAY_T>(_data(), x, size); |
sizeof(PEGASUS_ARRAY_T) * Array_size); |
#else |
CopyToRaw(Array_data, x, size); |
CopyToRaw(_data(), x, size); |
Array_size += size; |
#endif |
|
_rep->size += size; |
|
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T& x) |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 index, const PEGASUS_ARRAY_T& x) |
{ | { |
if (pos > size()) |
insert(index, &x, 1); |
ThrowOutOfBounds(); |
|
|
|
_copyOnWrite(); |
|
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 |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::insert(Uint32 pos, const PEGASUS_ARRAY_T* x, Uint32 size) |
void Array<PEGASUS_ARRAY_T>::insert( |
|
Uint32 index, const PEGASUS_ARRAY_T* x, Uint32 size) |
|
{ |
|
if (index > Array_size) |
{ | { |
if (pos + size > this->size()) |
throw IndexOutOfBoundsException(); |
ThrowOutOfBounds(); |
} |
| |
_copyOnWrite(); |
reserveCapacity(Array_size + size); |
reserve(this->size() + size); |
|
| |
Uint32 n = this->size() - pos; |
Uint32 n = Array_size - index; |
| |
if (n) | if (n) |
|
{ |
memmove( | memmove( |
_data() + pos + size, _data() + pos, sizeof(PEGASUS_ARRAY_T) * n); |
Array_data + index + size, |
|
Array_data + index, |
|
sizeof(PEGASUS_ARRAY_T) * n); |
|
} |
|
|
|
CopyToRaw(Array_data + index, x, size); |
|
Array_size += size; |
|
} |
| |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
#ifndef PEGASUS_ARRAY_T |
CopyToRaw<PEGASUS_ARRAY_T>(_data() + pos, x, size); |
template<class PEGASUS_ARRAY_T> |
#else |
|
CopyToRaw(_data() + pos, x, size); |
|
#endif | #endif |
_rep->size += size; |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 index) |
|
{ |
|
remove(index, 1); |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos) |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 index, Uint32 size) |
{ | { |
if (pos >= this->size()) |
if (Array_refs.get() != 1) |
ThrowOutOfBounds(); |
_rep = ArrayRep<PEGASUS_ARRAY_T>::copy_on_write(Array_rep); |
| |
_copyOnWrite(); |
// Case 1: attempting to remove last element (this is an optimization |
|
// for when the array is used as a stack; see Stack class). |
| |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
if (index + 1 == Array_size) |
Destroy<PEGASUS_ARRAY_T>(_data() + pos); |
{ |
#else |
Destroy(Array_data + index, 1); |
Destroy(_data() + pos); |
Array_size--; |
#endif |
return; |
|
} |
| |
Uint32 rem = this->size() - pos - 1; |
// Case 2: not attempting to remove last element: |
|
|
|
if (index + size - 1 > Array_size) |
|
{ |
|
throw IndexOutOfBoundsException(); |
|
} |
|
|
|
Destroy(Array_data + index, size); |
|
Uint32 rem = Array_size - (index + size); |
| |
if (rem) | if (rem) |
memmove(_data() + pos, _data() + pos + 1, sizeof(PEGASUS_ARRAY_T) * rem); |
{ |
|
memmove( |
|
Array_data + index, |
|
Array_data + index + size, |
|
sizeof(PEGASUS_ARRAY_T) * rem); |
|
} |
| |
_rep->size--; |
Array_size -= size; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::remove(Uint32 pos, Uint32 size) |
Uint32 Array<PEGASUS_ARRAY_T>::size() const |
{ | { |
if (pos + size > this->size()) |
return Array_size; |
ThrowOutOfBounds(); |
} |
|
|
_copyOnWrite(); |
|
| |
#ifdef PEGASUS_PLATFORM_HPUX_PARISC_ACC |
#ifndef PEGASUS_ARRAY_T |
Destroy<PEGASUS_ARRAY_T>(_data() + pos, size); |
template<class PEGASUS_ARRAY_T> |
#else |
|
Destroy(_data() + pos, size); |
|
#endif | #endif |
|
PEGASUS_ARRAY_T& Array<PEGASUS_ARRAY_T>::operator[]( |
|
Uint32 index) |
|
{ |
|
if (index >= Array_size) |
|
ArrayThrowIndexOutOfBoundsException(); |
| |
Uint32 rem = this->size() - (pos + size); |
if (Array_refs.get() != 1) |
|
_rep = ArrayRep<PEGASUS_ARRAY_T>::copy_on_write(Array_rep); |
| |
if (rem) |
return Array_data[index]; |
memmove( |
|
_data() + pos, _data() + pos + size, sizeof(PEGASUS_ARRAY_T) * rem); |
|
|
|
_rep->size -= size; |
|
} | } |
| |
#ifdef PEGASUS_HAS_EBCDIC |
|
|
|
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::etoa() |
const PEGASUS_ARRAY_T& Array<PEGASUS_ARRAY_T>::operator[]( |
|
Uint32 index) const |
{ | { |
#if PEGASUS_ARRAY_T == Sint8 |
if (index >= Array_size) |
_copyOnWrite(); |
ArrayThrowIndexOutOfBoundsException(); |
__etoa_l((char *)_data(),_rep->size); |
|
#endif |
return Array_data[index]; |
} | } |
| |
#ifndef PEGASUS_ARRAY_T | #ifndef PEGASUS_ARRAY_T |
template<class PEGASUS_ARRAY_T> | template<class PEGASUS_ARRAY_T> |
#else |
|
PEGASUS_TEMPLATE_SPECIALIZATION |
|
#endif | #endif |
void Array<PEGASUS_ARRAY_T>::atoe() |
Uint32 Array<PEGASUS_ARRAY_T>::getCapacity() const |
{ | { |
#if PEGASUS_ARRAY_T == Sint8 |
return Array_capacity; |
_copyOnWrite(); |
} |
__atoe_l((char *)_data(),_rep->size); |
|
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
#endif | #endif |
|
const PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::getData() const |
|
{ |
|
return Array_data; |
} | } |
| |
|
#ifndef PEGASUS_ARRAY_T |
|
template<class PEGASUS_ARRAY_T> |
#endif | #endif |
|
PEGASUS_ARRAY_T* Array<PEGASUS_ARRAY_T>::_data() const |
|
{ |
|
return Array_data; |
|
} |
| |
#endif /*defined(PEGASUS_EXPLICIT_INSTANTIATION) || !defined(PEGASUS_ARRAY_T)*/ |
#endif //!defined(Pegasus_ArrayImpl_h) || !defined(PEGASUS_ARRAY_T) |