std::vector<unsigned int> RemovedLevelFitnessFunction::removedCountRec(const htd::ITreeDecomposition & decomposition, htd::vertex_t node, double& totalCosts) const { std::vector<unsigned int> removedCount(app.getInputInstance()->quantifierCount(), 0); // child removals for (htd::vertex_t childNode : decomposition.children(node)) { std::vector<unsigned int> childRemovedCount = removedCountRec(decomposition, childNode, totalCosts); for (unsigned int index = 0; index < childRemovedCount.size(); index++) { removedCount.at(index) += childRemovedCount.at(index); } } // costs double removedWithLowerLevel = 0.0; for (htd::vertex_t variable : decomposition.forgottenVertices(node)) { unsigned int variableLevel = htd::accessLabel<int>(app.getInputInstance()->hypergraph->vertexLabel("level", app.getInputInstance()->hypergraph->vertexName(variable))); for (unsigned int index = 0; index < variableLevel; index++) { removedWithLowerLevel += removedCount.at(index); } } totalCosts += removedWithLowerLevel; // current removals for (htd::vertex_t variable : decomposition.forgottenVertices(node)) { unsigned int variableLevel = htd::accessLabel<int>(app.getInputInstance()->hypergraph->vertexLabel("level", app.getInputInstance()->hypergraph->vertexName(variable))); removedCount.at(variableLevel - 1) += 1; } return removedCount; }
// --------------------------------------------------------------------------- // CSdpMediaField::RemoveFormatL // --------------------------------------------------------------------------- // EXPORT_C void CSdpMediaField::RemoveFormatL(const TDesC8& aFormat) { if ( !iFormatList || iFormatList->Des().Length() == 0 ) { User::Leave( KErrSdpCodecMediaField ); } TLex8 lexer( *iFormatList ); TBool tokenRemoved( EFalse ); while ( !tokenRemoved && !lexer.Eos() ) { lexer.SkipSpaceAndMark(); lexer.SkipCharacters(); if ( lexer.TokenLength() > 0 ) { if ( aFormat.CompareF(lexer.MarkedToken()) == 0) { RArray<TInt> removedObjs; CleanupClosePushL( removedObjs ); for ( TInt i( 0 ); i < iFmtAttrFields->Count(); i++ ) { if (aFormat.CompareF((*iFmtAttrFields)[i]->Format()) == 0) { User::LeaveIfError( removedObjs.Append(i) ); } } // Remove all format attributes of type format TInt removedCount( 0 ); while ( removedObjs.Count() > 0 ) { CSdpFmtAttributeField* obj = (*iFmtAttrFields)[removedObjs[0] - removedCount]; delete obj; obj = 0; iFmtAttrFields->Remove( removedObjs[0] - removedCount); removedObjs.Remove(0); removedCount++; } CleanupStack::PopAndDestroy(); // removedObjs // Remove format from format list iFormatList->Des().Delete( lexer.MarkedOffset(), lexer.Offset() - lexer.MarkedOffset()); iFormatList->Des().TrimAll(); tokenRemoved = ETrue; } } } }
// --------------------------------------------------------------------------- // CSdpMediaField::KeepFormatL // --------------------------------------------------------------------------- // EXPORT_C void CSdpMediaField::KeepFormatL(const TDesC8& aFormat) { if ( !iFormatList ) { User::Leave( KErrSdpCodecMediaField ); } // Empty set will continue to be empty if ( iFormatList->Des().Length() > 0 ) { HBufC8* formatList = aFormat.AllocLC(); // Mark all format attributes not aFormat so that they will be deleted RArray<TInt> removedObjs; CleanupClosePushL( removedObjs ); for ( TInt i( 0 ); i < iFmtAttrFields->Count(); i++ ) { if (aFormat.CompareF((*iFmtAttrFields)[i]->Format()) != 0) { User::LeaveIfError( removedObjs.Append( i ) ); } } // Delete attribute fields TInt removedCount( 0 ); while ( removedObjs.Count() > 0 ) { CSdpFmtAttributeField* obj = (*iFmtAttrFields)[removedObjs[0] - removedCount]; delete obj; iFmtAttrFields->Remove( removedObjs[0] - removedCount ); removedObjs.Remove( 0 ); removedCount++; } CleanupStack::PopAndDestroy(); // removedObjs // Change format list delete iFormatList; iFormatList = formatList; CleanupStack::Pop(); // formatList } }