Questions tagged [cloning]

Cloning refers to the making of an exact copy (deep copy) of any kind of object. It is the opposite of shallow copying, in which a reference to particular object is copied, not the object itself.

Cloning refers to the making of an exact copy (deep copy) of any kind of object. It is the opposite of shallow copying, in which a reference to particular object is copied, not the object itself.

377 questions
3
votes
1 answer

Problem with HashSet Serialization / Cloning

Why is this failing? I am comparing the serialized form of an empty HashSet with the serialized form of its clone created by serialization+deserialization. import org.apache.commons.lang3.SerializationUtils; import static…
Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113
3
votes
0 answers

Issue with cloned website -domain hosting information missing in clone

When I cloned my web site with All-in-one WP Migration and overwrote another web site with this copy I lost the cloned website's domain hosting information how do I retrieve this? When I now lookup the cloned website on IICAN I get these…
SamBullen
  • 31
  • 1
3
votes
1 answer

How does ArrayList.clone() method work in Java?

I'm confused about the concept of cloning in Array lists. E.g : Balloon green = new Balloon("Green",new Address("greenState", "greencity")); Balloon green2 =…
rose
  • 41
  • 4
3
votes
2 answers

How to copy object methods in ES6

I want to clone an object using the spread operator. However, the methods are not copied as shown I am aware you could do Object.Assign() but I am looking for a way to do that using ES6 syntax The solution at Deep copy in ES6 using the spread syntax…
user9242543
3
votes
1 answer

How to inherit cloning methods properly?

I have a base class (A) and a delivered one (B). They inherit the ICloneable<> generic interface that I made: interface ICloneable { T Clone(); } I would like to override the A.Clone() method in B but so, that B.Clone() returns an object of…
florien
  • 487
  • 5
  • 16
3
votes
3 answers

Unable to clone repo from github Visual Studio 2013

I am trying to clone a project from github (https://github.com/bhilburn/powerlevel9k to be specific, but all github repos fail in the same way), using Visual Studio 2013's native git integration. I tried going to File -> Open From Source Control.…
Avi Caspe
  • 537
  • 4
  • 12
3
votes
2 answers

C++ copy constructors and assignments in cloneable hierarchy

There is well-known clone idiom for copying Derived objects via pointer to Base class. class Base{ int b; public: virtual unique_ptr clone() const = 0; virtual ~Base() = default; }; class Derived : public Base { int d; public: …
Dmitry J
  • 867
  • 7
  • 20
3
votes
3 answers

How to prevent a javascript/backbone.js cloned model from sharing attributes

I'm working with backbone.js models, so I don't know if my question is particular to the way backbone handles cloning or if it applies to javascript in general. Basically, I need to clone a model which has an attribute property assigned an object. …
user2095627
  • 362
  • 3
  • 7
3
votes
2 answers

Why Thread class doesn't support clone method?

/** * Throws CloneNotSupportedException as a Thread can not be meaningfully * cloned. Construct a new Thread instead. * * @throws CloneNotSupportedException * always */ @Override protected Object clone() throws…
3
votes
3 answers

How to clone an inherited object?

I've got a Tile class with this method: public object Clone() { return MemberwiseClone(); } And another class Checker that inherits from Tile. I also have a Board class that is a List. I want to clone the board, so I wrote…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
3
votes
2 answers

how to mark an object as Serializable

I have a system.document.table object and i want to mark that object as Serializable for deep cloning it. the exception is Type 'System.Windows.Documents.Table' in Assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral,…
jeevan_jk
  • 111
  • 2
  • 13
3
votes
2 answers

Effective Java Item 11: Override clone Judiciously

For a class with an array field Josh says if the clone method merely return super.clone(), the resulting class instance will have the correct values in primitive fields, but its array field will refer to the same array as the original class…
EMM
  • 1,812
  • 8
  • 36
  • 58
3
votes
1 answer

Why isn't there a default polymorphic cloning operator mechanism in c++?

I mean, a cloning operator, which by default use the copy constructor and new operator to return a new object. So that if the declaration in the base class is virtual, it would automatically provide a polymorphic cloning mechanism (any class should…
galinette
  • 8,896
  • 2
  • 36
  • 87
3
votes
1 answer

How to clone an Azure VM

Is there a simple method of cloning an Azure VM? So far I have found that you can "Deprovision" a VM, run "Sysprep" on it, and then "capture" an image. More on that here. It requires you to shutdown the Virtual Machine. What I had been hoping for…
Josh
  • 7,232
  • 8
  • 48
  • 75
3
votes
7 answers

What is better shallow or deep cloning?

I have a little confusion about object cloning in java. What is the main difference between shallow cloning and deep cloning? And which is much better ?
user
  • 65
  • 1
  • 8