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
-3
votes
1 answer

How to deep-copy objects

I have a complex data structure, which defines a type P, and I'd like to perform a deep copy of an instance of such a data structure. I have found this library but, considering the semantics of the Go language, wouldn't a method like the following…
Luca Marzi
  • 786
  • 2
  • 8
  • 24
-3
votes
1 answer

Java - copying parts of a list retrieved from database

I have taken data from a database and it is in List<> myList. There are 14 columns. I need to keep this list as it is for use later in the process I am doing. Is it possible to copy certain columns into a new list or an object? if it is possible,…
user10208767
-3
votes
1 answer

Remove from one list impact it's copy [python 2.7]

I created a copy of a list. When an item was removed from one copy - it was removed from the original as well. a = ['alpha', 'beta', 'gamma', 'delta'] b = a b.remove('alpha') print 'A list is', a print 'B list is', b How should I create an…
DarkLight
  • 79
  • 3
  • 16
-3
votes
1 answer

How to clone/copy an instance of my own class?

Is this way of using clone correct? I am getting a runtime error every time. Also can anybody suggest a way to write copy constructor in this class? public class Pair { final StringBuffer x; final StringBuffer y; public…
Learning
  • 89
  • 11
-3
votes
1 answer

Removing cloned nodes from list

I am making a filtereditems class, that will be displayed as a treeview in WPF. The filtereditems class contains only certain node items from a treeitems class that contain certain criteria. I am able clone all of the tree items and add them to the…
-3
votes
1 answer

can't solve error c2280 C++

i have a c2280 error in c++ and i don't know how to solve it. here is the code: #include #include #include #include "State.h" #include #define MAXIMUM_NUMBER_OF_STATES 1000 #define DELTA_Q 0.1 using namespace…
-4
votes
2 answers

structuredClone with function giving an error

I want to do a deep copy of an object which also has function as keys. So I do deepCopy = structuredClone(existingObjWithFns); However when this runs, I get the below error: Uncaught (in promise) DOMException: Failed to execute 'structuredClone'…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
-4
votes
2 answers

Deep Copying in C++

In C++ consider the two scenario, Returning object by reference. Returning object as it is. In which of the above cases deep copying is done and Why? Thanks in advance.
-4
votes
2 answers

Deep Copying Error

Dea All, I have the following: class test { int x = 6; int y = 7; private int getX() { return x; } private int getY() { return y; } public test copy() { test myTest = new test(); …
MrD
  • 4,986
  • 11
  • 48
  • 90
-4
votes
2 answers

C++ Implementing a copy constructor

I am writing some code to implement a deep copy of an object. Here is my code: //--------------------------------------------------------------------------- #pragma hdrstop #include #include #include #include…
Darryl Janecek
  • 399
  • 4
  • 9
  • 25
-5
votes
1 answer

correct algo for deep copying a string in c++

this is the code i have for deep copying a string in copy constructor so is the logic correct??I think there may be memory leak and i am trying to fix that.m.pStatus is initialised class Monkey { public: // insert your code…
-6
votes
1 answer

C++ Pointer arithmetic. No Operator "+" Matches these operands

I'm trying to preform a Deep Copy of one class to another. Using VS2015. below on *(clsOriginalToCopy + lngIndex); is where I get the error, I am at a loss. for (lngIndex = 0; lngIndex < lngSize; lngIndex += 1) { *(this + lngIndex) =…
Adam Schneider
  • 275
  • 1
  • 5
  • 18
-6
votes
1 answer

.contains() on a list of objects

I deep copied a list of objects into another list. The problem is using .contains() didn't work! Any ideas?
iAbdul
  • 1
  • 1
  • 1
  • 2
1 2 3
98
99