时间System.arraycopy的复杂性(...)? [英] Time complexity of System.arraycopy(...)?

查看:270
本文介绍了时间System.arraycopy的复杂性(...)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.arraycopy(对象SRC,INT srcPos,对象DEST,诠释destPos,INT的长度)是一个本地方法。

什么是这种方法的时间复杂度?

What is the time complexity for this method?

推荐答案

它必须要经过数组中的所有元素来做到这一点。阵列是一个独特的数据结构,你必须在初始化到指定大小。订单将源数组的大小或大O方面它的O(长度)。

It will have to go through all the elements in the array to do this. Array is a unique data structure where you have to specify a size when you initialize it. Order would be the source array's size or in Big O terms its O(length).

逸岸内部出现这种情况的一个ArrayList。 ArrayList的封装阵列。虽然和ArrayList看起来像一个动态增长的集合,在内部它的arrycopy当它有扩大。

Infact this happens internally in an ArrayList. ArrayList wraps an array. Although ArrayList looks like a dynamically growing collection, internally it does an arrycopy when it has to expand.

这篇关于时间System.arraycopy的复杂性(...)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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