|
What is the difference between a deep copy and a shallow copy?
Started by David Locke on
, 9 posts
by 9 people.
Answer Snippets (Read the full thread at stackoverflow):
Shallow:
Deep:
In object oriented programming, a type includes a collection of memberIn short, it depends....
= { firstName="Jane", lastname="Jones" }; var shallow = ShallowCopyOf(source); var deep = DeepCopyOf as the root node.
|
|
How would I best implement these? I thought of something like this:
using namespace std; shape_container shape_container::clone_deep () const { shape_container* ptr = new shape_container(); copy( data.begin(), data.end(), (*ptr).begin() ); return *ptr...
Started by Patrick Oscity on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Clone_shallow () const { return *this; }
If the data member is just a std::map instance, then it will be copied as part of your shallow clone in any case so there is no need to do the std::copy in the deep clone case, it's not trying....
|
|
Hi everyone,
After having been Taken in by the whole immersed planting and riparium style tanks on here and one awesome one on a forum over here in the uk, I thought I'd hang up my high tech gear, sell off my equipment and go for this.
Tank is lxdxh 1...
Started by Alastair-T on
, 12 posts
by 8 people.
Answer Snippets (Read the full thread at plantedtank):
Wasn't deep enough too keep my topsoil under but must say I'm really not impressed as it contained lots.
|
Ask your Facebook Friends
|
I wonder what is the fastest way to do shallow copying in C#? I only know there are 2 ways to do shallow copy:
MemberwiseClone Copy each field one by one (manual) I found that (2) is faster than (1). I'm wondering if there's another way to do shallow ...
Started by tep on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
Clone with Reflection
Shallow copy by default, can be re-written to do deep copy;)); _cachedIL.Add(typeof(T), myExec); } return ((Func<T, T>)myExec)(myObject); } }
For deep copy
Only creates a shallow....
To the same object.
|
|
Java.util.Calendar.clone() returns "...a new Calendar with the same properties" and returns "a shallow copy of this Calendar".
This does not appear to be a shallow copy as answered here on SO. That question is tagged language-agnostic, Java does not seem...
Started by Will on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
If you make a change to a deep copy, only the shallow copy has the....
A shallow copy is a copy on it, that affects all shallow copies of the object.
It's shallow or deep will not make a difference in that case.
|
|
Shallow/deep copy in java? let's say I have a Circle class which by default is white. It has a colorBlack method
if I do something like this
Circle A = new Circle();
Circle B = A;
A.colorBlack();
what is the color of B by the end of the command?
Started by Sicheng on
, 1 posts
by 1 people.
Answer Snippets (Read the full thread at yahoo):
|
|
This is my first time going out on opener on little bay and was just wondering if it was better in shallow or deeper water? I fished down in AuGres a lot and it seemed the walleye were shallow most of the time, we did catch some bigger ones in deeper ...
Started by bmead03 on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at outdoors911):
I did enough of that all winter! Go shallow between 12 and 5 feet got.
At a TV or computer screen...
|
|
Khamsin Jr both deep and shallow versions
Last edited by Mully on Mon Apr 28, 2008 1:05 am, edited 1 time in total.
Mully
"I Have the Body of a GOD but it sucks because its Buddha"
You can run - but you'll just die tired
Started by Mully on
, 10 posts
by 2 people.
Answer Snippets (Read the full thread at lureandmore):
Anyone used these babys before,I tried a few the other day on a very quiet day.Nothing was being taken this was the only one that got follows all the way to the bank...[The JR version in the red color]didnt score but got more of a look at than any other... .
|
|
I have a structure containing character arrays with no any other member functions. I am doing assignment operation between two instances of these structures. If I'm not mistaken, it is doing shallow copy. Is shallow copy safe in this case?
I've tried ...
Started by jasonline on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
The difference between shallow and deep is most meaningful when you have a type, but you could also say "shallow" vs "deep" doesn't even apply to other types, and they are justIf by "shallow copy....
Is each item in it.
|
|
Have a look at the following code you are not required to read the whole code just read the code of copy constructor and the main program.
the following statement in the copy constructor
//the statement below should do the shallow copy ptr[currentsize...
Started by Zia ur Rahman on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
EDIT:
Understand that when you do:
ptr=new t[size];
you're allocating a new that line to:
&ptr[currentsize++]=&object... .
For a shallow copy, just do:
ptr = object.ptr to do a deep copy...
In the second they stay intact.
In the first vector.
|