本文整理汇总了C++中deepCopy函数的典型用法代码示例。如果您正苦于以下问题:C++ deepCopy函数的具体用法?C++ deepCopy怎么用?C++ deepCopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deepCopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insert
inline void BinarySearchTree<T>::deepCopy(const BinarySearchTreeNode<T>* node)
{
if (node != NULL)
insert(node->value);
if (node->left != NULL)
deepCopy(node->left);
if (node->right != NULL)
deepCopy(node->right);
}
示例2: deepCopy
PQueue<ElemType> &PQueue<ElemType>::operator=(const PQueue &src) {
if (this != &src) {
delete[] arr;
deepCopy(src);
}
return *this;
}
示例3: main
int main () {
DataStruct dsOne;
DataStruct dsTwo;
DataStruct dsThree;
int data_two = 2;
// assign the datas to mainsOne
dsOne.data_one = 1;
dsOne.data_two = &data_two;
// shallow copy dsOne to dsTwo
memcpy(&dsTwo, &dsOne, sizeof(DataStruct));
// deep copy dsOne to dsThree
deepCopy(&dsThree, &dsOne);
// show the value of original data
printf("original data_one is %d,\noriginal data_two is %d\n\n", dsOne.data_one, *dsOne.data_two);
// change the data of dsOne
dsOne.data_one = 3;
*dsOne.data_two = 4;
// show the data of dsTwo after dsOne changed
// actually dsOne.data_two and dsTwo.data_two
// point to the same address, so the value of
// *dsTwo->data_two is changed
printf("data_one in dsTwo is %d,\ndata_two in dsTwo is %d\n\n", dsTwo.data_one, *dsTwo.data_two);
// show the data of dsThree after dsOne changed
// the address that dsThree.data_two points to and
// the address of dsOne.data_two are not the same,
// so *dsThree.data_two keep the original value.
printf("data_one in dsThree is %d,\ndata_two in dsThree is %d\n\n", dsThree.data_one, *dsThree.data_two);
system("PAUSE");
}
示例4: deepCopy
std::list<Scientist> ScientistRepository::list(std::string col, std::string mod) {
std::list<Scientist> outList = std::list<Scientist>();
outList = deepCopy();
Comparer comp = Comparer(col,mod);
outList.sort(comp);
return outList;
}
示例5: GraphObserver
ClusterGraph::ClusterGraph(
const ClusterGraph &C,
Graph &G,
ClusterArray<cluster> &originalClusterTable,
NodeArray<node> &originalNodeTable,
EdgeArray<edge> &edgeCopy)
:
GraphObserver(&G),
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;
deepCopy(C, G, originalClusterTable, originalNodeTable, edgeCopy);
}
示例6: insertItem
/*
Insert key = id, payload = value into the hash table.
Auto doubling the hash table if the size of the hash table reaches 2/3 of the capacity,
where 2/3 is the load factor.
*/
int insertItem(HashTable* table, char* id, Value* value){
if (table){
if ((table->size) >= ((table->capacity)*2/3)){
autoDouble(table);
}
int key = hash(table, id);
if (key == -1){
return 0;
}
int length = 0;
while (id[length]!='\0'){
length++;
}
length++;
char* copiedID = (char*)malloc(sizeof(char)*length);
strncpy(copiedID,id,length-1);
copiedID[length-1]='\0';
Value* keyVal = (Value*)malloc(sizeof(Value));
keyVal->type = symbolType;
keyVal->symbolValue = copiedID;
if ((table->entries)[key].cdr){
freeValue((table->entries)[key].cdr);
}
(table->entries)[key].car = keyVal;
(table->entries)[key].cdr = deepCopy(value);
(table->size)++;
return 1;
}
else{
return 0;
}
}
示例7: deepCopyFun
// deep copy the things in parse tree
Value* deepCopyFun(Value *function){
if (function){
Value *value = (Value *)malloc(sizeof(Value));
if (function->type == primitiveType){
value->type = primitiveType;
value->primitiveValue = function->primitiveValue;
return value;
}else if (function->type == closureType){
value->type=closureType;
value->closureValue = (Closure *)malloc(sizeof(Closure));
value->closureValue->body = deepCopy(function->closureValue->body);
value->closureValue->args = deepCopyLinkedList(function->closureValue->args);
value->closureValue->parent = function->closureValue->parent;
if (function->closureValue->identifier){
value->closureValue->identifier = (char *)malloc(sizeof(char)*(strlen(function->closureValue->identifier)+1));
strcpy(value->closureValue->identifier,function->closureValue->identifier);
value->closureValue->identifier[strlen(function->closureValue->identifier)] = '\0';
}else{
value->closureValue->identifier = NULL;
}
return value;
}else{
free(value);
}
}
return NULL;
}
示例8: clear
Lexicon& Lexicon::operator=(const Lexicon& src) {
if (this != &src) {
clear();
deepCopy(src);
}
return *this;
}
示例9: deepCopy
MSTableColumnGroup &MSTableColumnGroup::operator=(const MSTableColumnGroup &tableColumnGroup_)
{
if (&tableColumnGroup_!=this)
{
return deepCopy(tableColumnGroup_);
}
return *this;
}
示例10: Asset
//===========================================
// Sprite::Sprite
//===========================================
Sprite::Sprite(const Sprite& copy, long name)
: Asset(internString("Sprite")),
Entity(copy, name),
EntityAnimations(copy, this),
EntityTransformations(copy, this) {
deepCopy(copy);
}
示例11: return
Macro& Driver::macro( const HashedString& name ) {
std::pair< MacroMap::iterator, MacroMap::iterator > range = m_macros.equal_range( name );
if ( range.first == range.second ) {
return ( *m_macros.insert( std::make_pair( deepCopy( name.str() ), Macro() ) ) ).second;
} else {
return ( *( --range.second ) ).second;
}
}
示例12: deepCopy
/* \brief Sets the value of the Array at the specified index.
*
* \param id
* The ID of the type that the element should be.
*
* \param pos
* The index to create the item at.
*
* \param value
* The value of the element to create.
*/
void CS225::Array::Set(int id, int pos, int value)
{
deepCopy();
//setter will delete the old and create new
//slightly inefficient if new and old have the same type
delete data[pos];
data[pos] = pElementFactory->MakeElement(id,value);
}
示例13: deepCopy
void Driver::addMacro( const Macro & macro ) {
std::pair< MacroMap::iterator, MacroMap::iterator > range = m_macros.equal_range( macro.name() );
if ( range.first == range.second ) {
m_macros.insert( std::make_pair( deepCopy( macro.name() ), macro ) );
} else {
///Insert behind the other macros
m_macros.insert( range.second, std::make_pair( deepCopy( macro.name() ), macro ) );
Macro cp = this->macro( macro.name() );
assert( macro == cp );
}
#ifdef CACHELEXER
if( m_currentLexerCache )
m_currentLexerCache->addDefinedMacro( macro );
#endif
}
示例14: GraphObserver
ClusterGraph::ClusterGraph(const ClusterGraph &C,Graph &G)
: GraphObserver(&G), 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)
{
deepCopy(C,G);
m_clusterArrayTableSize = C.m_clusterArrayTableSize;
}
示例15: deepCopy
UBItem* UBGraphicsPolygonItem::deepCopy() const
{
UBGraphicsPolygonItem* copy = deepCopy(this->polygon());
copy->mOriginalLine = this->mOriginalLine;
copy->mOriginalWidth = this->mOriginalWidth;
copy->mIsNominalLine = this->mIsNominalLine;
return copy;
}