shallow-copy Questions

4

Solved

In a Mozilla developer translated Korean lang says 'slice method' returns a new array copied shallowly. so I tested my code. var animals = ['ant', 'bison', 'camel', 'duck', 'elephant']; var t = ...
Monck asked 10/12, 2017 at 11:25

2

Solved

How I can do git clone --depth 1 ... with JGIT library?
Sedimentation asked 13/7, 2012 at 17:17

3

Solved

I tried googling this but only objected oriented languages pop up as results. From my understanding a shallow copy is copying certain members of a struct. so lets say a struct is typedef struct ...
Chari asked 7/3, 2013 at 17:49

4

Solved

I understand spread syntax makes a shallow copy of objects, i.e., the cloned object refers to the same reference as the original object. However, the actual behaviour seems contradicting and confus...

6

Solved

Short Version Can I make a read-only list using Python's property system? Long Version I have created a Python class that has a list as a member. Internally, I would like it to do something every t...
Nettlesome asked 5/5, 2014 at 14:12

9

Solved

A struct can be either passed/returned by value or passed/returned by reference (via a pointer) in C. The general consensus seems to be that the former can be applied to small structs without pena...
Autarchy asked 22/6, 2015 at 13:5

6

Solved

I sometimes get across this way of printing or returning a list - someList[:]. I don't see why people use it, as it returns the full list. Why not simply write someList, whithout the [:] part?
Sob asked 30/4, 2015 at 9:15

2

Solved

I am extremely confused for days now regarding the true definition of a shallow copy and a deep copy. When I read the mdn docs (https://developer.mozilla.org/en-US/docs/Glossary/Shallow_copy) on sh...
Luck asked 12/5, 2022 at 1:45

7

Solved

I just came across this concept of var copy = Object.assign({}, originalObject); which creates a copy of original object into the "copy" object. However, my question is, does this way of...
Banquette asked 29/12, 2015 at 5:0

2

Solved

I have never experimented with languages like C, C++, Go, etc., and I decided to start with Rust, I already understand a little what the stack and the Heap are, but, what does it really mean by mov...
Jurkoic asked 22/3, 2022 at 17:49

1

GMP provides methods for initializing and assigning an mpz_t. A call to mpz_init_set(a, b) will assign to a the content of b. However, I assume, this performs a deep copy on b. On my project I need...
Berkshire asked 24/2, 2012 at 14:53

3

Solved

I want to shallow copy a list in Scala. I wanted to do somehing like: val myList = List("foo", "bar") val myListCopy = myList.clone But the clone method is protected.
Exacting asked 18/9, 2009 at 16:32

2

This should be a pretty basic question, but I've been having a little trouble finding a definite answer. When you have an array of values and you use the .ToArray() method does it create a deep o...
Salas asked 30/4, 2012 at 16:49

5

I am trying to create a --shallow-since working clone from a local bare clone but it keeps pulling everything. --depth=N works fine. I'm thinking the issue is I'm using the wrong format? I've trie...
Duncandunce asked 9/5, 2017 at 20:22

4

Solved

To reword the question in case someone types it into the search bar differently: Is pass-by-value the same as making a deep copy, and is pass-by-reference the same as making a shallow copy? If not...

4

Solved

Strings are considered reference types yet can act like values. When shallow copying something either manually or with the MemberwiseClone(), how are strings handled? Are they considred separate an...
Articulation asked 3/2, 2009 at 10:29

3

Solved

As per the example given here, let first:number[] = [1, 2]; let second:number[] = [3, 4]; let both_plus:number[] = [0, ...first, ...second, 5]; console.log(`both_plus is ${both_plus}`); first[0] ...
Predict asked 26/4, 2018 at 20:13

11

Solved

Say I have a class, something like the following; class MyClass { public: MyClass(); int a,b,c; double x,y,z; }; #define PageSize 1000000 MyClass Array1[PageSize],Array2[PageSize]; If my cl...
Sunward asked 11/6, 2010 at 8:34

11

Solved

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. Tha...
Genethlialogy asked 24/7, 2009 at 3:32

1

Solved

related to why should I make a copy of a data frame in pandas I noticed that in the popular backtesting library, def __init__(self, data: pd.DataFrame) data = data.copy(False) in row 631. Wha...
Quasi asked 14/8, 2019 at 12:43

8

Solved

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 tha...
Feces asked 8/6, 2009 at 19:13

2

Solved

case class Person(var firstname: String, lastname: String) val p1 = Person("amit", "shah") val p2 = p1.copy() p1.firstname = "raghu" p1 p2 p1 == p2 As i went through some documentation which sa...
Restless asked 24/10, 2018 at 10:31

31

Solved

What is the difference between a deep copy and a shallow copy?
Stelly asked 8/10, 2008 at 20:22

3

Does the default copy-constructor do a shallow or a deep copy in C++? I am really confused with default copy constructor in cpp, as it does shallow copy or deep copy, as when I did v2=v1; suppose ...
Epileptic asked 18/7, 2018 at 15:40

1

Solved

I don't fully understand the docs, so I've tried clone, and it seems if there is an attribute of a mutable class, it can be changed in the new object using the old one (and that's what I don't wa...
Manned asked 27/4, 2018 at 20:36

© 2022 - 2024 — McMap. All rights reserved.