Scala中的Array和WrappedArray有什么区别

Scala中的Array和WrappedArray有什么区别

本文介绍了Scala中的Array和WrappedArray有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我对这两个系列感到有些困惑.

I'm a bit confused in terms of those 2 collections.

我知道Scala的Array会调用Java API.在这种情况下,包装阵列的作用是什么(及其性能特征)?

I understand that Scala's Array calls Java API. In such a case, what's the role of a Wrapped Array (and its performance characteritics)?

http://www.scala-lang. org/api/current/scala/collection/mutable/WrappedArray.html

谢谢!

推荐答案

WrappedArray包装Array为其提供了额外的功能.它也有很多类型,而数组仅扩展可序列化和可克隆,这允许将数组包装起来,因此可以在需要某些通用集合类型(例如Seq)的地方使用.

WrappedArray wraps an Array to give it extra functionality. It also have a bunch of types while array extends only serializable and cloneable, This allows an array to be wrapped so it can be used in places where some generic collection type like Seq is required.

ArrayOps也是值得注意的,它与WrappedArray相似,因为它通过额外的操作丰富了Array.区别在于ArrayOps中的操作返回常规Array,而WrappedArray中的操作返回WrappedArray

Also notable is ArrayOps Which is similar to WrappedArray in that it enriches an Array with extra operations. The difference is that Operations inArrayOps return a regular Array while operations from WrappedArray return a WrappedArray

ArrayOps的优先级高于WrappedArray,因此将使用它,除非需要WrappedArray提供的一种类型.

ArrayOps has priority over WrappedArray so it will be used unless one of the types provided by WrappedArray is needed.

这篇关于Scala中的Array和WrappedArray有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:57