|
From: Frank V. C. <fr...@us...> - 2001-03-01 16:33:05
|
Update of /cvsroot/corelinux/clfw/src/libs/clfw
In directory usw-pr-cvs1:/tmp/cvs-serv19117/src/libs/clfw
Modified Files:
Array.cpp MetaType.cpp SetCollection.cpp
Log Message:
233863 SetCollection
Index: Array.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/Array.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Array.cpp 2001/03/01 03:20:16 1.5
--- Array.cpp 2001/03/01 16:34:28 1.6
***************
*** 187,190 ****
--- 187,191 ----
// Iterate through each, calling equal
//
+ GUARD;
return checkForMember( aPtr );
***************
*** 330,333 ****
--- 331,344 ----
}
+ /// Remove all entries
+
+ void Array::removeAll( void )
+ {
+ GUARD;
+ UnsignedInt bv( theSizeRestriction.getValue() );
+ this->resetState();
+ theSizeRestriction.setValue(bv);
+ }
+
//
// Assignment operator for Array Reference
***************
*** 467,471 ****
// Fast path
! if( aCollection.getType()->isTypeOf( this->getType() ) == true )
{
(*this) += (ArrayCref)aCollection;
--- 478,482 ----
// Fast path
! if( Array::getTypeDescriptor()->isTypeOf( aCollection.getType() ) == true )
{
(*this) += (ArrayCref)aCollection;
***************
*** 488,494 ****
{
! if( this->equals( &aCollection ) == false )
{
! if( aCollection.getType()->isTypeOf( this->getType() ) == true )
{
if( checkBoundsForAdd(aCollection.getSize()) == false )
--- 499,505 ----
{
! if( this != &aCollection )
{
! if( Array::getTypeDescriptor()->isTypeOf( aCollection.getType() ) == true )
{
if( checkBoundsForAdd(aCollection.getSize()) == false )
***************
*** 545,549 ****
bool Array::checkForMember( FrameworkEntityCptr aPtr ) const
{
- GUARD;
bool found( false );
--- 556,559 ----
Index: MetaType.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/MetaType.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** MetaType.cpp 2000/11/15 23:07:21 1.17
--- MetaType.cpp 2001/03/01 16:34:28 1.18
***************
*** 329,344 ****
bool MetaType::isTypeOf( MetaTypeCptr aTypePtr ) const throw ( Assertion )
{
! REQUIRE( aTypePtr != NULLPTR );
- bool aTypeOf( false );
-
- aTypeOf = this->isType( aTypePtr );
-
if( aTypeOf == false )
{
! MetaTypeFixedIterator<MetaTypePtr> aIterator(theParents);
while( aIterator.isValid() )
{
! if( aIterator.getElement()->isTypeOf( aTypePtr ) == true )
{
aTypeOf = true;
--- 329,340 ----
bool MetaType::isTypeOf( MetaTypeCptr aTypePtr ) const throw ( Assertion )
{
! bool aTypeOf( this->isType( aTypePtr ) );
if( aTypeOf == false )
{
! MetaTypeFixedIterator<MetaTypePtr> aIterator(aTypePtr->theParents);
while( aIterator.isValid() )
{
! if( this->isTypeOf( aIterator.getElement() ) == true )
{
aTypeOf = true;
Index: SetCollection.cpp
===================================================================
RCS file: /cvsroot/corelinux/clfw/src/libs/clfw/SetCollection.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SetCollection.cpp 2001/03/01 03:20:16 1.1
--- SetCollection.cpp 2001/03/01 16:34:28 1.2
***************
*** 40,53 ****
}
! SetCollection::SetCollection( SetCollectionCref )
:
! Array()
{
! ;
}
! SetCollection::SetCollection( ArrayCref )
:
! Array()
{
;
--- 40,53 ----
}
! SetCollection::SetCollection( SetCollectionCref aRef )
:
! Array( aRef )
{
! ; // do nothing
}
! SetCollection::SetCollection( ArrayCref aRef )
:
! Array( aRef )
{
;
***************
*** 67,71 ****
bool SetCollection::operator==( SetCollectionCref aCref ) const
{
! return compareMembers( aCref );
}
--- 67,72 ----
bool SetCollection::operator==( SetCollectionCref aCref ) const
{
! GUARD;
! return (compareMembers( aCref ) == 0 );
}
***************
*** 88,91 ****
--- 89,199 ----
}
+ // Assignment operators
+
+ SetCollectionRef SetCollection::operator=( ArrayCref aRef )
+ {
+ //
+ // Because the array may have dupes, we need to clean it up
+ // first
+ //
+
+ Array *aPtr( this->foldToArray(aRef) );
+ Array::operator=( *aPtr );
+ Array::destroy( aPtr );
+
+ return ( *this );
+ }
+
+ SetCollectionRef SetCollection::operator=( SetCollectionCref aRef )
+ {
+ Array::operator=( Array::castDown(aRef) );
+ return ( *this );
+ }
+
+ SetCollectionRef SetCollection::operator=( ArrayCptr aPtr )
+ throw (NullPointerException)
+ {
+ if( aPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ return ( (*this)=*aPtr );
+ }
+
+ SetCollectionRef SetCollection::operator=( SetCollectionCptr aPtr )
+ throw (NullPointerException)
+ {
+ if( aPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ return ( (*this)=*aPtr );
+ }
+
+ // Copy (append) operators
+
+ SetCollectionRef SetCollection::operator+=( ArrayCref aRef )
+ throw (BoundsException)
+ {
+ //
+ // Because the array may have dupes, we need to clean it up
+ // first
+ //
+
+
+ Array *aPtr( this->foldToArray(aRef) );
+ this->addAll( Collection::castDown(*aPtr) );
+ Array::destroy( aPtr );
+ return ( *this );
+ }
+
+ SetCollectionRef SetCollection::operator+=( SetCollectionCref aRef )
+ throw (BoundsException)
+ {
+ this->addAll( Collection::castDown(aRef) );
+ return ( *this );
+ }
+
+ SetCollectionRef SetCollection::operator+=( ArrayCptr aPtr )
+ throw (NullPointerException, BoundsException)
+ {
+ if( aPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ (*this) += *aPtr;
+ return ( *this );
+ }
+
+ SetCollectionRef SetCollection::operator+=( SetCollectionCptr aPtr )
+ throw (NullPointerException, BoundsException)
+ {
+ if( aPtr == NULLPTR )
+ {
+ throw NullPointerException( LOCATION );
+ }
+ else
+ {
+ ; // do nothing
+ }
+
+ this->addAll( Collection::castDown(*aPtr) );
+ return ( *this );
+ }
// Add to end (putBack)
***************
*** 128,144 ****
}
! // Add all the elements from the inbound collection
! void SetCollection::addAll( CollectionCref )
throw (BoundsException,IncompatibleClassException)
{
}
// Add all the elements from the inbound collection at a offset
! void SetCollection::addAll( Index, CollectionCref )
throw (BoundsException,IncompatibleClassException)
{
}
--- 236,289 ----
}
! // Add all the elements from the inbound collection acts
! // like a union set operation, that is it adds the elements
! // from the collection that don't exist in the set
! void SetCollection::addAll( CollectionCref aCollection )
throw (BoundsException,IncompatibleClassException)
{
+ if( Array::getTypeDescriptor()->isTypeOf( aCollection.getType() ) == true )
+ {
+ ArrayPtr aPtr = this->getMembers( aCollection, false );
+ if( aPtr->getSize() != 0 )
+ {
+ Array::operator+=( *aPtr );
+ Array::destroy( aPtr );
+ }
+ else
+ {
+ ; // nothing to do
+ }
+ }
+ else
+ {
+ throw IncompatibleClassException( LOCATION );
+ }
}
// Add all the elements from the inbound collection at a offset
!
! void SetCollection::addAll( Index offset, CollectionCref aCollection )
throw (BoundsException,IncompatibleClassException)
{
+ if( Array::getTypeDescriptor()->isTypeOf( aCollection.getType() ) == true )
+ {
+ ArrayPtr aPtr = this->getMembers( aCollection, false );
+ if( aPtr->getSize() != 0 )
+ {
+ Array::addAll( offset, *aPtr );
+ Array::destroy( aPtr );
+ }
+ else
+ {
+ ; // nothing to do
+ }
+ }
+ else
+ {
+ throw IncompatibleClassException( LOCATION );
+ }
}
***************
*** 146,166 ****
// Do the walk, iterators would be more useful
! bool SetCollection::compareMembers( SetCollectionCref aRef ) const
{
! bool matched( false );
! Count maxCount( aRef.getSize() );
try
{
! for( Count x = 0; (x < maxCount) && (matched == false); ++x )
{
! matched = Array::checkForMember( aRef.getElementAt( x ) );
}
}
catch( BoundsExceptionRef aRef )
{
! ; // breaks us out with matched == false
}
! return !(matched);
}
--- 291,375 ----
// Do the walk, iterators would be more useful
! Count SetCollection::compareMembers( CollectionCref aRef ) const
{
! Count notMatched( 0 );
! Count maxCount( aRef.getSize() );
! ArrayCref ar( Array::castDown(aRef) );
try
{
! for( Count x = 0; x < maxCount ; ++x )
{
! if( Array::checkForMember( ar.getElementAt( x ) ) == false )
! {
! ++notMatched;
! }
! else
! {
! ; // do nothing
! }
}
}
catch( BoundsExceptionRef aRef )
{
! notMatched = maxCount;
! }
! return notMatched;
! }
!
! // Do the walk, extracting non-like members
!
! ArrayPtr SetCollection::getMembers( CollectionCref aRef, bool comp ) const
! {
! ArrayPtr aPtr( Array::create() );
! ArrayCref ar( Array::castDown(aRef) );
! Count maxCount( ar.getSize() );
!
! try
! {
! for( Count x = 0; x < maxCount; ++x )
! {
! FrameworkEntityPtr aFEP( ar.getElementAt(x) );
!
! if( Array::checkForMember( aFEP ) == comp )
! {
! aPtr->put( aFEP );
! }
! else
! {
! ; // do nothing
! }
! }
!
! }
! catch( BoundsExceptionRef aRef )
! {
! aPtr->removeAll();
! }
!
! return aPtr;
! }
!
! // Remove dupes
!
! ArrayPtr SetCollection::foldToArray( ArrayCref ar ) const
! {
! ArrayPtr aPtr( Array::create() );
! Count maxCount( ar.getSize() );
!
! for( Count x = 0; x < maxCount; ++x )
! {
! FrameworkEntityPtr aFEP( ar.getElementAt(x) );
!
! if( aPtr->containsElement( aFEP ) == false )
! {
! aPtr->put( aFEP );
! }
! else
! {
! ; // do nothing
! }
}
! return aPtr;
}
|