深拷贝和浅拷贝有什么区别? [英] What is the difference between a deep copy and a shallow copy?

查看:200
本文介绍了深拷贝和浅拷贝有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

深层副本和浅层副本之间有什么区别?

What is the difference between a deep copy and a shallow copy?

推荐答案

浅层副本尽可能少。集合的浅副本是集合结构的副本,而不是元素的副本。有了浅的副本,两个集合现在共享单个元素。

Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.

深度复制一切。集合的深层副本是两个集合,其中原始集合中的所有元素都重复。

Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.

这篇关于深拷贝和浅拷贝有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆