当前位置:网站首页>关于数组复制问题
关于数组复制问题
2022-04-23 08:11:00 【雄狮少年】
文章目录
本来就有两个开辟过空间的数组,只需要交换两个数组的内容(本质是改交换两个数组名指针的指向)
int[] tem = heapArr[cur];
heapArr[cur] = heapArr[parent];
heapArr[parent]= tem;
无中生有型(只有一个开辟过空间的数组, 需要再复制一个一模一样的数组,且其中一个内容变化,另一个不跟着变化)
这时候就需要 开辟一片空间,然后使用Arrays.copyOf(数组名称(源数组),要拷贝多长的片段(从数组起点开始 计算))函数
例如:
Arrays.copyOf(Array,Array.length)
tem = Arrays.copyOf(heapArr[cur],2);
heapArr[cur] = Arrays.copyOf(heapArr[child],2);
heapArr[child] = Arrays.copyOf(tem,2);
版权声明
本文为[雄狮少年]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_52034121/article/details/124340167
边栏推荐
- okcc呼叫中心外呼系统智能系统需要用多大的盘存录音?
- Description of the abnormity that the key frame is getting closer and closer in the operation of orb slam
- DOM 学习之—添加+-按钮
- Introduction to protobuf
- lgb,xgb,cat k折交叉验证
- Word plus watermark
- 面了一圈,整理了这套面试题。。
- JSP page coding
- Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
- Campus transfer second-hand market source code download
猜你喜欢
ansible自動化運維詳解(一)ansible的安裝部署、參數使用、清單管理、配置文件參數及用戶級ansible操作環境構建
QT reading and writing XML files
excle加水印
Transformer XL: attention language modelsbbeyond a fixed length context paper summary
Listed on the Shenzhen Stock Exchange: the market value is 5.2 billion yuan. Lu is the East and his daughter is American
There are some problems when using numeric type to query string type fields in MySQL
根据字节码获取类的绝对路径
项目上传部分
AQS & ReentrantLock 实现原理
PgSQL wants to implement all kinds of column sub query operations of MySQL
随机推荐
Record: JS several methods to delete one or more items in the array
Input / output system
A simple theme of Typecho with beautiful appearance_ Scarfskin source code download
stm32以及freertos 堆栈解析
form表单 post提交 数据量大的问题
DOM learning - add + - button
QFileDialog 选择多个文件或文件夹
万物互联下如何对设备进行加密
DOM 学习之—添加+-按钮
'bully' Oracle enlarged its move again, and major enterprises deleted JDK overnight...
396. Rotate Function
DOM学习笔记---遍历页面所有元素节点
Excle plus watermark
jsp页面编码
Overview of bus structure
[explanation] get ora-12838: cannot read / modify an object after modifying it in parallel
rust 使用tokio的Notify 和timeout实现类似可超时条件变量的效果
Trust uses Tokio's notify and timeout to achieve the effect similar to the timeout condition variable
My heart's broken! A woman's circle of friends envied others for paying wages on time and was fired. Even her colleagues who liked her were fired together
一键清理项目下pycharm和Jupyter缓存文件