当前位置:网站首页>关于数组复制问题
关于数组复制问题
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
边栏推荐
- Large amount of data submitted by form post
- freertos学习02-队列 stream buffer message buffer
- pgsql想实现mysql一样样的列子查询操作
- Situational leaders - Chapter 7, solving performance problems
- K210学习笔记(二) K210与STM32进行串口通信
- 作文以记之 ~ 二叉树的前序遍历
- LINQ Learning Series ----- 1.4 anonymous objects
- npm安装yarn
- Qtablewidget header customization and beautification developed by pyqt5 (with source code download)
- LINQ学习系列-----1.4 匿名对象
猜你喜欢
作文以记之 ~ 二叉树的前序遍历
正点原子携手OneOS直播 OneOS系统教程全面上线
WordPress love navigation theme 1.1.3 simple atmosphere website navigation source code website navigation source code
The annotation is self-defined by implementing the parameter parser handlermethodargumentresolver interface
一个必看的微信小程序开发指南1-基础知识了解
Input / output system
作文以记之 ~ 二叉树的后序遍历
让地球少些“碳”息 度能在路上
【学习】从零开始的音视频开发(9)——NuPlayer
根据字节码获取类的绝对路径
随机推荐
SYS_CONNECT_BY_PATH(column,'char') 结合 start with ... connect by prior
Word plus watermark
ajax防止缓存方法
jsp页面编码
pdf加水印
获取TrustedInstaller权限
线程的调度(优先级)
WordPress love navigation theme 1.1.3 simple atmosphere website navigation source code website navigation source code
excle加水印
正点原子携手OneOS直播 OneOS系统教程全面上线
监控智能回放是什么,如何使用智能回放查询录像
Record: JS several methods to delete one or more items in the array
Goland 调试go使用-大白记录
项目上传部分
CGM optimizes blood glucose monitoring and management -- Yiyu technology appears in Sichuan International Medical Exchange Promotion Association
万物互联下如何对设备进行加密
Failed to convert a NumPy array to a Tensor(Unsupported Object type int)
JVM工具之Arthas使用
RPC过程
JS common array methods