Questions tagged [deep-copy]

A deep copy of an object is a separate, fully independent duplicate of that object, such that any references / pointers it holds to other objects refer to deep copies of those to which the original's refer. Use this tag for questions regarding implementing or using deep copying methods.

Deep copying is a process by which an object is fully duplicated to create a copy that is wholly independent of the original. This differs from shallow copying with respect to the treatment of references / pointers to other objects: deep copying makes a deep copy of each referenced object, too, whereas shallow copying copies only the references. Deep copying is "deep" in the sense that it traverses the object's reference graph all the way to the bottom.

Related tags

Links

1483 questions
0
votes
2 answers

Do structs automatically decompose to memory locations?

How does C handle copying structs (not pointer to structs) with the assignment operator. I have a sample program below demonstrating my question. struct s { char string[20]; }; void main() { struct s var1, var2; strcpy(var1.string, "hello"); …
0
votes
2 answers

Efficient simultaneous update of objects in a list, possibly involving copying. How?

Suppose I have a list g (In practice a doubly nested list which is three dimensions, but here it's simplified to one dimension for clarity.) g = [1,2,3,2,1] I want a function that can make g[x] = g[x-1]+g[x]. An incorrect way would be def…
shimao
  • 312
  • 2
  • 6
  • 15
0
votes
3 answers

clone() and system.arracopy() of an array creates two arrays with different references in Java?

Firstly I have to say this is not a duplicate of deep copying vs shallow copying (clone) in Java. but it is related to that. I have read other posts on deep vs shallow copying in SO and while working on this, I found some problem with my…
brain storm
  • 30,124
  • 69
  • 225
  • 393
0
votes
1 answer

Redefine deep copy/delete/assignment in a simple hierarchy

I'm learning C++ and I have a some doubts about the deep copy, delete and assignment in this programming exercise; I've this simple hierarchy with an abstract base class: class AudioFile{ private: string title; double size; …
Roberto Milani
  • 760
  • 4
  • 20
  • 40
0
votes
1 answer

XNA - Copying a Model

I am working on a game and I have a List of available characters each player chooses from, each character contains a (3D)Model and a Texture2D Icon that has been loaded in through the Content Pipeline. The issue is, I want more than one player to…
0
votes
1 answer

Deep copy into block of c-array on heap

Consider for example a template container class that holds a buffer that is allocated on the heap: T *_buffer = new T[SIZE] Just a simple pointer to c array of type T. This class is templated. However I am having issues with performing a deep copy…
Igneous01
  • 719
  • 1
  • 10
  • 24
0
votes
3 answers

Python deepcopy changes the reference to an object

Hi: This is a follow up to this question: How to copy all python instances to a new class? The problem is that deepcopy() is not copying the objects correctly, this can be seen through this working code: from kivy.app import App from…
I want badges
  • 6,155
  • 5
  • 23
  • 38
0
votes
3 answers

Python: writing a function that tests if list1 is a shallow copy of list2

To test if lst1 is a shallow copy of lst2, I did this: def check_shallow_copy(lst1, lst2): ''' Return True if lst1 is a shallow copy of lst2. Return False if not. ''' for idx in range(len(lst1)): if lst1 == lst2 and id(lst1[idx]) ==…
user2489861
  • 109
  • 4
  • 11
0
votes
1 answer

mapping soap request from source to target using dozer

I am creating a wrapper around an external service, docusign. I am trying to use dozer to map my wrapper service objects to docusign objects. I am trying to do a deep copy. I have tried to keep both the source and target names in most cases - but…
user123
  • 1
  • 1
0
votes
2 answers

How to pass a pointer to array of structures into a function

pointers always get me in C programing. I am having trouble, I want to pass a pointer to an array of structs into a function so it can modify the structs and then pass the members of the array can be used in other functions later. The problem is…
Elena
  • 77
  • 2
  • 9
0
votes
1 answer

IE8 cloneNode(true) object doesn't support this property or method

$('#attachment-deletion').cloneNode(true); IE reports Object doesn't support this property or method what can I do about this? cloneNode was my solution to IE8 not recognizing jquery's clone method, which it didn't even throw an error about
CQM
  • 42,592
  • 75
  • 224
  • 366
0
votes
0 answers

Cancelling all changes and setting back to initially data through deep copy

In my application I store all data in static list AllData, it inherited from; public class GenericList : BindingList, IList I set user's changes to AllData's selected item and my problem is about cancelling changes. If user cancels…
Furkan Ekinci
  • 2,472
  • 3
  • 29
  • 39
0
votes
3 answers

How to change the frame of a view when a variable value changes?

In my viewcontroller, there are few views. All of that view's frames are depends on the variable CGFloat borderWidth These views are defined like sec1 = [[MSSectionView alloc]initWithFrame:CGRectMake(self.borderWidth,…
manujmv
  • 6,450
  • 1
  • 22
  • 35
0
votes
1 answer

Cocos2d: child already added, adding 2 similar children without deep copy

Cocos2d does not allow two similar objects to be added as child of self is there another way of adding a duplicate without implementing deep copy in my DigBackground class? and doing (DigBackground *)[idObject copy]; btw! isn´t this racism against…
Tom Lilletveit
  • 1,872
  • 3
  • 31
  • 57
0
votes
1 answer

Hibernate object tree outside transaction?

I'm implementing a kind of JobProcessor that takes long running jobs. These Jobs use information, basically Page, PageField and PageRelation, that define a tree of pages and each page has its own PageFields. tl;dr How to easily copy a Object…
Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121