Node* Node::deepCopy() { Node* newCopy = shallowCopy(); for (size_t i = 0; i < children.size(); i++) if (children[i]) newCopy->children[i] = children[i]->deepCopy(); return newCopy; }
ClusterGraph &ClusterGraph::operator=(const ClusterGraph &C) { clear(); shallowCopy(C); m_clusterArrayTableSize = C.m_clusterArrayTableSize; reinitArrays(); OGDF_ASSERT_IF(dlConsistencyChecks, consistencyCheck()); return *this; }
ClusterGraph::ClusterGraph(const ClusterGraph &C) : GraphObserver(&(C.getGraph())), m_clusterIdCount(0),m_postOrderStart(0), m_rootCluster(0), m_nClusters(0), m_lcaNumber(0), m_lcaSearch(0), m_vAncestor(0), m_wAncestor(0), m_allowEmptyClusters(1), m_updateDepth(false), m_depthUpToDate(false) { shallowCopy(C); m_clusterArrayTableSize = C.m_clusterArrayTableSize; }
Mantid::API::IFunction_sptr ConvFitModel::getFittingFunction() const { auto function = shallowCopy(IndirectFittingModel::getFittingFunction()); auto composite = boost::dynamic_pointer_cast<CompositeFunction>(function); IFunction_sptr background(nullptr); if (composite && m_backgroundIndex) background = removeFunction(composite, *m_backgroundIndex); return createConvolutionFitModel(function, background, m_temperature); }
PETScVector::PETScVector(const PETScVector &existing_vec, const bool deep_copy) { shallowCopy(existing_vec); // Copy values if(deep_copy) { VecCopy(existing_vec._v, _v); } }
/* Update an existing element */ static int updateElement(Ejs *ejs, EjsXML *list, EjsXML *elt, int index, EjsObj *value) { EjsXML *node; int i, j; if (!ejsIsXML(ejs, value)) { /* Not XML or XMLList -- convert to string */ value = ejsCast(ejs, value, String); // TODO - seem to be doing this in too many places } mprSetItem(list->elements, index, value); if (elt->kind == EJS_XML_ATTRIBUTE) { assure(ejsIs(ejs, value, String)); i = mprLookupItem(elt->parent->elements, elt); assure(i >= 0); ejsSetXMLElement(ejs, elt->parent, i, elt); // TODO - why do this. Doesn't above do this? ejsSetPropertyByName(ejs, elt->parent, elt->qname, value); elt->value = (EjsString*) value; } if (ejsIsXML(ejs, value) && ((EjsXML*) value)->kind == EJS_XML_LIST) { value = (EjsObj*) shallowCopy(ejs, (EjsXML*) value); if (elt->parent) { index = mprLookupItem(elt->parent->elements, elt); assure(index >= 0); for (j = 0; j < mprGetListLength(((EjsXML*) value)->elements); j++) { mprInsertItemAtPos(elt->parent->elements, index, value); } } } else if (ejsIsXML(ejs, value) || elt->kind != EJS_XML_ELEMENT) { if (elt->parent) { index = mprLookupItem(elt->parent->elements, elt); assure(index >= 0); mprSetItem(elt->parent->elements, index, value); ((EjsXML*) value)->parent = elt->parent; if (ejsIs(ejs, value, String)) { node = ejsCreateXML(ejs, EJS_XML_TEXT, N(NULL, NULL), list, (EjsString*) value); mprSetItem(list->elements, index, node); } else { mprSetItem(list->elements, index, value); } } } else { ejsSetPropertyByName(ejs, elt, N(NULL, "*"), value); } return index; }
AAFRESULT ImplAAFTypeDef::MergeTo( ImplAAFDictionary* pDstDictionary ) { ASSERTU( pDstDictionary ); AAFRESULT hr = AAFRESULT_SUCCESS; aafUID_t typeID; GetAUID( &typeID ); ImplAAFTypeDef* pDstTypeDef = 0; if( AAFRESULT_FAILED( pDstDictionary->LookupTypeDef( typeID, &pDstTypeDef ) ) ) { OMClassFactory* pDstFactory = dynamic_cast<OMClassFactory*>( pDstDictionary->metaDictionary() ); // New storable object returned by shallowCopy() is // reference counted ImplAAFTypeDef. OMStorable* pDstStorable = shallowCopy( pDstFactory ); ImplAAFTypeDef* pDstTypeDef = dynamic_cast<ImplAAFTypeDef*>( pDstStorable ); ASSERTU( pDstTypeDef ); hr = pDstDictionary->RegisterTypeDef( pDstTypeDef ); if( AAFRESULT_SUCCEEDED(hr) ) { pDstTypeDef->onCopy( 0 ); deepCopyTo( pDstTypeDef, 0 ); } // pDstTypeDef created by shallowCopy() is reference counted. pDstTypeDef->ReleaseReference(); pDstTypeDef = 0; } else { pDstTypeDef->ReleaseReference(); pDstTypeDef = 0; } return hr; }
ClusterGraph::ClusterGraph(const ClusterGraph &C) : GraphObserver(&(C.constGraph())), m_lcaSearch(0), m_vAncestor(0), m_wAncestor(0) { m_clusterIdCount = 0; m_postOrderStart = 0; m_rootCluster = 0; m_allowEmptyClusters = true; m_updateDepth = false; m_depthUpToDate = false; m_nClusters = 0; m_lcaNumber = 0; m_clusterArrayTableSize = C.m_clusterArrayTableSize; shallowCopy(C); }
CardList::CardList (const CardList &cl) { shallowCopy(cl); }
//! Expand into a copy of itself Node* ImmediateNode::expandVectorialNodes(std::wostream *dump, Compiler* compiler, unsigned int index) { assert(index == 0); return shallowCopy(); }
void StringTestCase::testOwnership() { // Test shallow copy semantics { Sid::String orig("foo bar"); Sid::String shallowCopy(orig); CPPUNIT_ASSERT_MESSAGE("Shallow copy semantics for copy c'tor not working!", orig.data() == shallowCopy.data()); Sid::String assigned; assigned = orig; CPPUNIT_ASSERT_MESSAGE("Shallow copy semantics for assignment operator" " not working!", orig.data() == assigned.data()); } // Test copy-on-write semantics { Sid::String orig("foo bar"); { Sid::String copy(orig); copy+=" baz"; CPPUNIT_ASSERT_MESSAGE("Copy-on-write semantics not working for " "operator+=(const char*).", copy != orig); } { Sid::String copy(orig); copy+=Sid::String("baz"); CPPUNIT_ASSERT_MESSAGE("Copy-on-write semantics not working for " "operator+=(const Sid::String&).", copy != orig); } { Sid::String copy(orig); copy=Sid::String("baz"); CPPUNIT_ASSERT_MESSAGE("Copy-on-write semantics not working for " "operator=(const Sid::String&).", copy != orig); } { Sid::String copy(orig); copy="baz"; CPPUNIT_ASSERT_MESSAGE("Copy-on-write semantics not working for " "operator=(const char*).", copy != orig); } } // Test deepCopy() { Sid::String orig("foobar"); const char* origData = orig.data(); Sid::String dCopy = orig.deepCopy(); CPPUNIT_ASSERT_MESSAGE("deepCopy() yielded a shallow copy!", orig.data() != dCopy.data()); CPPUNIT_ASSERT_MESSAGE("deepCopy() caused original to relinquish its reference!", orig.data() == origData); Sid::String copy(orig); CPPUNIT_ASSERT_MESSAGE("deepCopy() caused original to relinquish its reference!", orig.data() == origData); } }