FAQ Database Discussion Community


clone one interface in another of the same type in c++

c++,pointers,interface,clone,value
I want to make a copy of one object of one specific type of interface with another of the same interface, here i will write 2 class examples and their output. This is class Vehicle: #ifndef _VEHICLE_ #define _VEHICLE_ class Vehicle { public: Vehicle(int a): val(a) {} virtual ~Vehicle() {}...

JavaScript: Deep Copy Circular JSON

javascript,json,clone,deep-copy
intro: I'm trying to write a deep copy method, but need to keep track of my visited nodes, so that I can link to the previously visitedNode instead of deep copying forever until stack overflow. attempts: var visitedNodes = {}; var obj = {}; obj.a = obj; // circular; can't...

jQuery draggable clone size while dragging

jquery,resize,clone,draggable
I'm developping a drag-and-drop application. I have a droppable container and draggable. $( "#dragshock" ).draggable( { helper: "clone", cursor: 'move', drag: resizeContainer } ); The function called by drag is this one: function resizeContainer(e, ui) { var defaultSize = 108; var factor = ((ui.position.top)/19); var correcteSize = defaultSize + factor;...

Java ArrayList clone improved run-time

java,list,arraylist,clone
This is the question:https://leetcode.com/problems/combinations/ This is my solution 1: public class Solution { public List<List<Integer>> combine(int n, int k){ List<List<Integer>> result = new ArrayList<List<Integer>>(); combine(n, k, 1, result, new ArrayList<Integer>()); return result; } public void combine(int n, int k , int start, List<List<Integer>> result, ArrayList<Integer> l){ if(k == 0){ result.add(l);...

Purpose of cloning in Java

java,c++,clone,cloneable
I was going through the "special" features of Java, and started reading up on Cloning. So currently what I understand is Cloning can be used to get a identical copy of an object. To do this you implement the Cloneable interface and override the clone method of Object(Which is really...

not valid: is this a git repository?

git,github,clone,gerrit,gitblit
My question is NOT this question. On performing a git clone I am getting this error. Command than I am using is: $ git clone "https://gdt.test.com/gitblit/log/?r=mytest.git&h=refs/heads/branch_development" EDIT 1: On simply running: $ git clone "https://gdt.test.com/gitblit/log/?r=mytest.git" I get the error: fatal: could not create work tree dir '?r=mytest'.: Invalid argument EDIT...

Linq2Sql Clone an Object C#

c#,asp.net,linq,linq-to-sql,clone
tblAgreement AgreementOld = (from g in TDC.tblAgreements where g.AccountID == ids.accountID && g.AgreementID == AgreementID select g).SingleOrDefault(); Guid AgreementIDNew = Guid.NewGuid(); var AgreementNew = AgreementOld; AgreementNew.AgreementID = AgreementIDNew; AgreementNew.StatusChangeDate = DateTime.Now; AgreementNew.CreationDate = DateTime.Now; AgreementNew.AccountID = ids.accountID; AgreementNew.CreatedByID = ids.userID; TDC.tblAgreements.InsertOnSubmit(AgreementNew); I am trying to create a new object with...

How to clone JDT ICompilationUnit

java,eclipse,clone,jdt
I need to get a copy (deep clone) from org.eclipse.jdt.core.ICompilationUnit. Any suggestion?

jQuery, get all the values of all cloned input fields

jquery,html,clone
Need some help or pointers to achieve the following. Cloning input fields on click and retrieving the values of the fields on change so they get pasted as text into another div. However it only seems to work for the original hard coded fields (not the cloned ones). I have...

cloning a private bitbucket repository given access to me

git,clone,bitbucket
I need to clone a repository from Bitbucket that I was given access to by another user. I tried this: git clone [email protected]:repositoryOwnerUserName/repo.git It gave me an error message: Permission denied(publickey). How I can clone this repository?...

jQuery Clone and renaming child elements

javascript,jquery,find,clone,addclass
I have a DIV Element with an image, some text, a url link to the image and a link to a status of the image this status is represented by an icon next to the image I use .on("click"..., event to trigger a phpscript that updates the status in thebackground...

Clone / Remove TR Row - Almost working

jquery,clone
I'm using the code I found in this fiddle and it is almost perfect for what I need. The code allows me to clone another TR and have the option to delete the cloned rows. The issue I have is I don't want to be able to delete all rows....

Most efficient way to clone a list into an existing list, minimizing memory reallocation?

c#,performance,list,memory-management,clone
I have a need to clone an existing list into another, existing list. As the environment demands very high performance, I need to eliminate unnecessary memory reallocation. The most efficient algorithm I can think of is the following, which will increase the capacity of the destination list to match the...

WebComponents: Remove cloned template

javascript,html5,clone,web-component
I'm using the webcomponentsjs polyfill. No x-tag, polymer, etc. preferably vanilla JS. After cloning a template and appending it to the document I'm not able to remove it again since it's missing a parentNode. var tmpl = document.getElementById('tmpl'); var clone = document.importNode(tmpl.content, true); document.body.appendChild(clone); console.log(clone.parentNode); // parentNode is null (not...

How to select a single cloned element?

jquery,jquery-selectors,clone
I am dynamically adding a div to my webpage when ever I click a button. I am doing this by cloning an original div and appending the clone. I have the above figured out. However, within the cloned div there is a text input. I want to make sure the...

jQuery: easier way to use .clone() than described below?

javascript,jquery,html,class,clone
If you execute in the console on this page var cloned = $(".question").clone(true); $(".question").addClass("first"); var clonedStr = cloned[0].outerHTML || new XMLSerializer().serializeToString(cloned[0]); $(".question").after(clonedStr); you will clone the question (there will be two questions on the page, but the first one will be with the .first class). That's what is needed. Is...

Getting clone of superclass

swift,clone,subclass,superclass
Here is my playground snippet: class Box { func clone() -> Box { return Box() // <- how to return superclass here? } } class VBox:Box { } let vb = VBox() let cBox = vb.clone() // now cBox is a Box, not a VBox My clone function returns a...

Cloning a branch other than master on GitHub

git,github,clone
On GitHub, if I have two branches, master and master_copy. Is there are way for me to clone the master_copy branch instead of the master branch? Even when I select master_copy, when I get the link to the clone the repo, it just gives me the master branch link....

How do I reconnect my project to my existing GitHub repository

git,github,clone
I am working on an Xcode project with source control. I messed up so I deleted the project from my laptop, and downloaded (ZIP) my own project which I pushed to GitHub earlier. But now this cloned project is not a git repository (or any of the parent directories): .git...

How to clone a struct storing a trait object?

struct,clone,rust,traits,cloneable
I wrote a program that has trait Animal and struct Dog implementing the trait and struct AnimalHouse storing an animal as trait object Box<Animal>. trait Animal{ fn speak(&self); } struct Dog{ name: String } impl Dog{ fn new(name: &str) -> Dog { return Dog{name: name.to_string()} } } impl Animal for...

Block “cloner” servers rendering content from our server

apache,seo,clone,cracking
I have a website of mine (freeofficefinder.com) that is being cloned (see here: thelawyerserviceratings.org) There are actually over 25 websites that are currently cloning our website. Obviously this is hurting our SEO ranking greatly due to "duplicate content". Is there something that I could add to the Apache config file...

abstract class implements Cloneable; abstract Object clone()

java,clone,abstract-class
Lets say I have this class: public abstract class AbstractFoo implements Cloneable { public abstract Object clone(); } And the subclass: public class Foobar extends AbstractFoo { @Override public Object clone() { try { Foobar c = (Foobar) super.clone(); /* some operations */ return c; } catch (CloneNotSupportedException e) {...

Is it possible to clone existing cloud code already deployed on server side, through the Parse command line tool?

parse.com,terminal,clone,cloud-code,command-line-tool
How can I clone an existing Parse Cloud Project files to my computer with the command line tool? I tried parse new and selected a project but it created a folder with new files, not the files that I already had in the Parse Cloud. Note: I did not find...

Is it possible to implement the “virtual constructor” pattern in C# without casts?

c#,clone,covariance,contravariance
I'm writing a program that writes C# that eventually gets compiled into an application. I would like each of the generated types to provide a "deep clone" function which copies the entire tree of data. That is, I want someone to be able to do: var x = new Base();...

Is it possible to copy a div from a website to another?

jquery,static,copy,clone,common-code
is it possible to copy a div from a site to another? Managing many websites I need to copy some static portions of code (e.g. a common footer) without having to go on every website and change it. I was looking to use jQuery, I know about the .clone() but...

Jquery: cloning a table and its first row

jquery,clone
I have a standard table structure like this: <table id="test"> <th>...</th> <tr><td>one thing</td></tr> <tr><td>another</td></tr> ... ... </table> I know how to clone the entire table, or the nth row of a table, but what I need is the whole thing, EXCEPT the 2nd, 3rd, 4th etc row of the table,...

How can I clone an object and set every properties value to null?

javascript,object,clone
As per title, I need to clone an object in Javascript like that below and set each values to zero. Of course the object properties can change. { _id: { action: null, date: null }, avg: null, min: null, max: null, total: null } ...

Node.js and lodash - clone JSON object returning only specific element

json,node.js,clone,lodash
I have a requirement to clone a JSON object however drop specific elements. I am attempting to use lodash clone(). Test code: var _ = require('lodash'); var obj = { "config": { "items": [ { "k1": "foo", "k2": "xx", "k3": "yy" }, { "k1": "bar", "k2": "zz", "k3": "aa" }...

Object array clone with subset of properties

javascript,arrays,clone
What is the most efficient way in JavaScript to clone an array of uniform objects into one with a subset of properties for each object? UPDATE Would this be the most efficient way to do it or is there a better way? - var source = [ { id: 1,...

Deep Cloning of Custom Linked List

java,linked-list,clone,deepclone
I am trying to implement clone method for deep clonning of custom linked list(of Rectangle objects). I am able to get the correct value when there is no element or only a single element in the list but not when there are more than one element in the list. I...

How to clone an object from PHP extension

c,clone,php-extension
I am trying to implement the prototype design pattern in my extension. How can I clone an object from an zval*. Is there a zend function equivalent to the userland clone operator? Update I wrote the following function for cloning an object. Not sure if there is a better way....

Deep Copy of Complex Third Party Objects/Classes [duplicate]

c#,clone,automapper,deep-copy,valueinjecter
This question already has an answer here: Deep cloning objects 25 answers I'm have been working on a project to create PDF forms using PDFView4Net. While the library is generally good, the forms creator is primitive and lacking basic features (such as copy/paste, alignment, formatting, etc.) when working with...

Append cloned child node to cloned node

java,dom,clone,appendchild
Presume the following XML: <outer> <entity> <id>123</id> <subnode1> <subnode2> </entity> <entity> <id>124</id> <subnode1> <subnode2> </entity> </outer> Overall, I want to split the entity nodes into separate files. I have extracted the entity nodes and stored them within a Map with the corresponding text value as map key. This is absolutely...

HG clone - abort : HTTP Error 403: Forbidden/empty destination path not valid

mercurial,clone,abort
Basically, I'm trying to serve (hg serve) my local repository and clone the same. When I gave "hg clone http://localhost:8000/" (the served URL), I got "abort: HTTP Error 403: Forbidden" When I did "unset http_proxy", tried again, abort: empty destination path is not valid popped up! Why does it happen?...

clone() method in ArrayList, why Arrays.copyOf()?

java,arraylist,clone
I try to get my head straight about cloning in Java with my own ArrayList. For what I see this code @Override public Object clone() { try { MyArrayList<E> v = (MyArrayList<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, size); return v; } catch (CloneNotSupportedException e) { throw new InternalError(); } } Gives...

How to have two JComboBox with the same elements?

java,swing,clone,jcombobox,comboboxmodel
I have a list (ArrayList) with elements that I want to show in two JComboBox so both of them show the same elements but when you choose some elements in one JComboBox the other one must not change. What I do now is to create two DefaultComboBoxModel and add the...

Add row below using jquery

php,jquery,ajax,row,clone
I would like to add row exactly all the same as before, with all the elements as well. Here i have two select options. First, i choose the category, then the product will show up and also i choose product too. After that i choose the quantity, and then the...

Create and Copy a select box with jquery

javascript,jquery,select,clone
We want to make a new select box and copy its options from another select box when an event happens. We use below code: //Create a new select box and add it to a div $('#content').append("<select id='destination'/>"); //Create copy source options var $options = $("#source > option").clone(); //Append source option...

In C#, what are some rules of thumb for _where_ to clone objects?

c#,clone,srp,responsibility
Here's the situation: I am trying to determine the where part of cloning an object to avoid modifying the original. I have two options: Clone the object in the caller and pass the cloned object to a method ("callee"), thus preventing potential modification by the callee. Clone the object in...

How to copy text file in python

python,file,text,clone
Here's what I want to do: import copy def printtext(swefile): for row in swefile: print(row) text = open("wordsv.txt","r",encoding="utf-8") text2 = copy.copy(text) printtext(text) print(text2.readlines()) But it is not possible, TypeError: cannot serialize '_io.TextIOWrapper' object. So I wonder if there is a good method for "cloning" the text variable, so that I...

Clone divs, then fill them with arrays

javascript,jquery,clone,frontend
with the aim to speed-up my prototyping phase, I want to clone my divs and then fill them with some content stored into an array. Here is some generic content who needs to be cloned: <li class="shots--li"> <img class="image" src="images/dribbble.png"> <h1>Title</h1> <p>Description</p> </li> I already know how to clone: $(document).ready(function()...

Lua - Function That Creates Detours

class,oop,pointers,lua,clone
I need to make several detours to various functions and doing it one by one is just not an option. I'm looking for a function that will take a table, ideally, and this table is class. Loop through it and for each key, value pair that is a function make...

Can TXL be used for code clone detection

c++,frameworks,clone,detection
Can we use TXL language for code clone detection (especially for analyzing C/C++ codes) considering only Text-based and Token-based Approaches? If yes, then can we further integrate it with a framework to make a final dashboard which can be used to detect the clones....

Cloneable throws CloneNotSupportedException

java,clone,cloneable
public class test implements Cloneable { @Override public test clone() { return (test) super.clone(); } public static void main(String[] args) { new test().clone(); } } I get error: unreported exception CloneNotSupportedException when I try to compile this (at line 4, not the main). As far as I can tell, the...

Implementing ICollection.CopyTo in C#: deep or shallow copy?

c#,copy,clone,interface-implementation
I'm writing a custom class which implements IDictionary, and I'm not sure what to do about CopyTo. Should each element just be copied to the target array (shallow copy), or should I make a copy/clone of each element then place it in the target array (deep copy)?

Bootstrap Toggle for Checkbox adding extra div

jquery,checkbox,toggle,clone,bootstrap-switch
We have a form where users can create a shipping type by entering a name in a text field and optionally toggle a checkbox. To add another shipping type, we use jQuery's clone method to rebuild the fields one or more times. My goal is to change the checkbox into...

c++ clone function in abstract class

c++,c++11,inheritance,clone
in c++11 standard, if class B inherits from class A, then 'B is an A'. However, i am still confused regarding this notion: look at this code: class Base { public: virtual ~Base() {} virtual Base* clone() const = 0; }; class Derived : public Base { public: virtual Base*...

BUG? Physijs Clone does not retain Phsyijs properties (collide-ability)

clone,physijs
In Physijs, I created a "bumper" cylinder mesh for a sphere to ricochet off of. I then cloned the mesh, positioned the clones (and for this example, the original mesh) and added them to a "ground" box, like this: // CREATE AND CLONE A BUMPER bumper = new Physijs.CylinderMesh (...

Jquery clone form values and replace form field id

javascript,jquery,regex,clone
I am trying to clone a row to keep the values in my text box and comments field and doing a regex expression to do a partial replace of the id from crs1 to crs2. However, I am not able to get this to work. <div id="wrapper"> <div id="info-crs1">Course Information...

“invalid initialization of non-const reference of type…” Error in clone() function

c++,templates,clone
Good day I am busy to implement linear data structure in c++. I am struggeling with my clone() function. The one line code seems in order for me, but maybe the error is in the copy constructor. The error I am getting: linkedList.C:22:32: error: invalid initialization of non-const reference of...

Clone, append and remove

jquery,append,clone
I have a couple of items as such <div class="item"> <figure> <span class="overlay"></span> <img...> <figcaption> <h3>Title</h3> </figcaption> </figure> </div> I am trying to clone figcaption h3 so that when the item is clicked the figcaption h3 is appended to overlay and when another item is clicked the title of the...

Cloning an existing shopify site to a new site

clone,shopify
I want to be able to clone an instance of an existing shopify site into a new shopify site. (This is in order for me to create a test / staging environment) Are there are any tools or scripts out there which could help me achieve this? The clone should...

Java - Clone list that holds references to original List

java,list,copy,clone
I don't know exactly how copying a List in Java works. I have this code: List<String> copy = new ArrayList<String>(original); Would this make a new List called copy that just holds references to the objects in the original list? (This is what I want). Or would it make new string...

git: fatal: I don't handle protocol '​​http'

git,clone,whitespace
I copy and pasted an git clone command from a web page: https://fedorahosted.org/ibus-typing-booster/ I got this: [email protected]> git clone ​​http://git.fedorahosted.org/git/ibus-typing-booster.git Cloning into 'ibus-typing-booster'... fatal: I don't handle protocol '​​http' I took me some time to find the bug, that's why I answer my own question below...

Getting full commit history after git clone

git,clone,reflog
I'm the lone developer on a project where I'm working across multiple computers, some on VM. After doing a git clone of my repo on gitHub, calls to reflog only show items after the clone. How can I update this new cloned repo to show the full history?

Clone table row and increment IDs by 1

jquery,html,clone
In my js code below I am cloning the last row of my table and attempting to increment the IDs by one. function addNewRow() { $('#FinancialDataTable tbody').append($('#FinancialDataTable tbody tr:last').clone()); $('#FinancialDataTable tr').each(function(i) { $(this).find('tr:last'); var selectinput = $(this).find('select'); var textinput = $(this).find('input'); var textarea = $(this).find('textarea'); i++; selectinput.eq(0).attr('id', 'FinancialItem'+i); textinput.eq(0).attr('id', 'FinancialAmount'+i);...

How clone has more performance than object creation

java,performance,clone,cloneable
I'm trying to understand what's happening underneath the clone() method in java, I would like to know how is better than doing a new call public class Person implements Cloneable { private String firstName; private int id; private String lastName; //constructors, getters and setters @Override protected Object clone() throws CloneNotSupportedException...

Clone tree data structure with back references?

c#,clone
I want to clone a tree of objects, where every node also references the parent node: How do I avoid cloning parents more than once at a time? Every node is a Guy. When I clone the root guy who has no parent, I clone its children and children's children....