当前位置: 首页>>代码示例>>C++>>正文


C++ deepCopy函数代码示例

本文整理汇总了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);
	}
开发者ID:VuKevin,项目名称:Binary_Search_Tree,代码行数:11,代码来源:BinarySearchTree.cpp

示例2: deepCopy

    PQueue<ElemType> &PQueue<ElemType>::operator=(const PQueue &src) {
		if (this != &src) {
			delete[] arr;
			deepCopy(src);			
		}
		return *this;
	}
开发者ID:ej2xu,项目名称:cs106b,代码行数:7,代码来源:pqheap.cpp

示例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");
}
开发者ID:benbai123,项目名称:C_Cplusplus_Practice,代码行数:34,代码来源:struct_practice_002__copy_struct.c

示例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;
}
开发者ID:Hopur12,项目名称:VLN1,代码行数:7,代码来源:scientistrepository.cpp

示例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);
}
开发者ID:Alihina,项目名称:ogdf,代码行数:26,代码来源:ClusterGraph.cpp

示例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;
  }
}
开发者ID:alabid,项目名称:scheme_interpreter,代码行数:39,代码来源:value.c

示例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;
}
开发者ID:alabid,项目名称:scheme_interpreter,代码行数:28,代码来源:value.c

示例8: clear

Lexicon& Lexicon::operator=(const Lexicon& src) {
    if (this != &src) {
        clear();
        deepCopy(src);
    }
    return *this;
}
开发者ID:chuzui,项目名称:courses,代码行数:7,代码来源:lexicon.cpp

示例9: deepCopy

MSTableColumnGroup &MSTableColumnGroup::operator=(const MSTableColumnGroup &tableColumnGroup_)
{
    if (&tableColumnGroup_!=this)
    {
        return deepCopy(tableColumnGroup_);
    }
    return *this;
}
开发者ID:seanstickle,项目名称:aplus,代码行数:8,代码来源:MSTableColumnGroup.C

示例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);
}
开发者ID:yuang1516,项目名称:dodge,代码行数:11,代码来源:Sprite.cpp

示例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;
  }
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:8,代码来源:driver.cpp

示例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); 
}
开发者ID:beentaken,项目名称:mmeng-personal-work,代码行数:19,代码来源:array.cpp

示例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
}
开发者ID:serghei,项目名称:kde3-kdevelop,代码行数:17,代码来源:driver.cpp

示例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;
}
开发者ID:boddulavineela,项目名称:ICSE-2011-ViewInfinity,代码行数:9,代码来源:ClusterGraph.cpp

示例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;
}
开发者ID:Vetal3000,项目名称:Sankore-3.1,代码行数:9,代码来源:UBGraphicsPolygonItem.cpp


注:本文中的deepCopy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。