|
From: Frank V. C. <fr...@us...> - 2001-02-25 15:18:41
|
Update of /cvsroot/corelinux/clfw/src/libs/clfw
In directory usw-pr-cvs1:/tmp/cvs-serv19666/src/libs/clfw
Modified Files:
Array.cpp
Log Message:
233863 Completing Array
Index: Array.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/Array.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Array.cpp 2001/02/24 16:28:07 1.2
--- Array.cpp 2001/02/25 15:19:52 1.3
***************
*** 65,68 ****
--- 65,87 ----
theRemaining( 0 )
{
+ //
+ // Using the information from the reference
+ // construct our initial state
+ //
+
+ theSizeRestriction.setValue
+ (
+ anArrayRef.getSizeRestrictionAsReference().getValue()
+ );
+
+ this->increaseArraySize( anArrayRef.size() );
+
+ //
+ // Now copy the data from the reference to our
+ // internal array
+ //
+
+ this->copyOverFromArray( 0, anArrayRef.getArray(), anArrayRef.size() );
+ this->increaseOccupancy( anArrayRef.size() );
}
***************
*** 73,77 ****
Array::~Array( void )
{
! ; // do nothing
}
--- 92,96 ----
Array::~Array( void )
{
! resetState();
}
***************
*** 117,120 ****
--- 136,143 ----
}
+ //
+ // Get indexed entity
+ //
+
FrameworkEntityPtr Array::getElementAt( Index offset ) const
throw (BoundsException)
***************
*** 181,184 ****
--- 204,211 ----
}
+ //
+ // The main mover indexed insertions
+ //
+
void Array::putAt( Index offset, FrameworkEntityPtr anEntity )
throw (NullPointerException,BoundsException)
***************
*** 202,205 ****
--- 229,236 ----
}
+ //
+ // Index removal of entity
+ //
+
FrameworkEntityPtr Array::removeAt( Index offset )
throw (BoundsException)
***************
*** 242,251 ****
ArrayRef Array::operator=
(
! ArrayCref aArray
)
{
! if( this != &aArray )
{
GUARD;
}
else
--- 273,304 ----
ArrayRef Array::operator=
(
! ArrayCref anArray
)
{
! if( this != &anArray )
{
GUARD;
+ this->resetState();
+
+ //
+ // Using the information from the reference
+ // construct our initial state
+ //
+
+ theSizeRestriction.setValue
+ (
+ anArray.getSizeRestrictionAsReference().getValue()
+ );
+
+ this->increaseArraySize( anArray.size() );
+
+ //
+ // Now copy the data from the reference to our
+ // internal array
+ //
+
+ this->copyOverFromArray( 0, anArray.getArray(), anArray.size() );
+ this->increaseOccupancy( anArray.size() );
+
}
else
***************
*** 274,278 ****
if( this != aArray )
{
! GUARD;
}
else
--- 327,331 ----
if( this != aArray )
{
! (*this) = *aArray;
}
else
***************
*** 285,288 ****
--- 338,403 ----
}
+ ArrayRef Array::operator+=( ArrayCref anArray )
+ throw (BoundsException)
+ {
+ if( this != &anArray )
+ {
+ if( checkBoundsForAdd(anArray.size()) == false )
+ {
+ throw BoundsException( LOCATION );
+ }
+ else
+ {
+ GUARD;
+
+ //
+ // Using the information from the reference
+ // adjust and append
+ //
+
+ CountCref aSize( anArray.size() );
+
+ this->increaseArraySize( aSize );
+
+ //
+ // Now append the data from the reference
+ //
+
+ this->copyOverFromArray( this->size(),anArray.getArray(), aSize );
+ this->increaseOccupancy( aSize );
+ }
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ return ( *this );
+ }
+
+ /// Copy (append)
+
+ ArrayRef Array::operator+=( ArrayCptr anArrayPtr )
+ throw (NullPointerException,BoundsException)
+ {
+ if( anArrayPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ (*this) += (*anArrayPtr);
+ }
+ return ( *this );
+ }
+
+
+ // Expose list
+
+ FrameworkEntity **Array::getArray( void ) const
+ {
+ return theEntities;
+ }
+
// Consume
***************
*** 311,315 ****
if( theRemaining == 0 || increment > theRemaining )
{
! UnsignedInteger aR = getSizeRestriction();
if( aR.getValue() != 0 &&
--- 426,430 ----
if( theRemaining == 0 || increment > theRemaining )
{
! UnsignedIntegerCref aR = getSizeRestrictionAsReference();
if( aR.getValue() != 0 &&
***************
*** 342,346 ****
{
Count growth = (theCount+increment)+theCount/2;
! FrameworkEntityPtr *newArray = new FrameworkEntityPtr[growth];
for( Count x=0; x<theCount ; ++x )
--- 457,462 ----
{
Count growth = (theCount+increment)+theCount/2;
! FrameworkEntity **newArray =
! (FrameworkEntity **) new FrameworkEntityPtr[growth];
for( Count x=0; x<theCount ; ++x )
***************
*** 376,381 ****
memmove
(
! &theEntities[position],
! &theEntities[position+increment],
sizeMove
);
--- 492,497 ----
memmove
(
! &theEntities[position+increment],
! &theEntities[position],
sizeMove
);
***************
*** 391,400 ****
memmove
(
! &theEntities[position+increment],
! &theEntities[position],
sizeMove
);
}
! //! version for the Array MetaType
const DwordCref version(1);
--- 507,557 ----
memmove
(
! &theEntities[position],
! &theEntities[position+increment],
sizeMove
);
+ }
+
+ //
+ // Copy blocks into starting at index
+ //
+
+ void Array::copyOverFromArray
+ (
+ Index startPos,
+ FrameworkEntity **aSrc,
+ CountCref maxCount
+ )
+ {
+ size_t sizeCopy = maxCount * sizeof( FrameworkEntityPtr );
+
+ memcpy
+ (
+ &theEntities[startPos],
+ &aSrc[0],
+ sizeCopy
+ );
+ }
+
+ // Helper
+
+ void Array::resetState( void )
+ {
+ if( theEntities != NULLPTR )
+ {
+ delete [] theEntities;
+ theEntities = NULLPTR;
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ theCount = 0;
+ theRemaining = 0;
+ theSizeRestriction.setValue(0);
}
!
! // version for the Array MetaType
const DwordCref version(1);
|