简体   繁体   English

Kotlin:LinkedList实现

[英]Kotlin: LinkedList Implementation

Why does Kotlin not have a LinkedList implementation in the Kotlin Standard Library (stdlib)? 为什么Kotlin在Kotlin标准库(stdlib)中没有LinkedList实现?

If I'm working with Kotlin in the JVM I'm using the Java LinkedList source . 如果我在JVM中使用Kotlin,我正在使用Java LinkedList 源代码

Is there an equivalent in the stdlib (in particular regarding Kotlin Native Development)? stdlib中是否存在等价物(特别是关于Kotlin Native Development)?

Kotlin does not have its own collections because it would be too difficult to maintain Java interoperability. Kotlin没有自己的集合,因为维护Java互操作性太难了。 Instead, the Kotlin Standard Library just adds some extension functions to the Java collections to make them easier to work with. 相反,Kotlin标准库只是为Java集合添加了一些扩展函数,以使它们更易于使用。

To quote Kotlin in Action : 引用Kotlin的行动

Why are there no Kotlin collections? 为什么没有Kotlin系列? Because using the standard Java collections makes it much easier to interact with Java code. 因为使用标准Java集合可以更容易地与Java代码交互。 You don't need to convert collections one way or the other when you call Java functions from Kotlin or vice versa. 当您从Kotlin调用Java函数时,您不需要以某种方式转换集合,反之亦然。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM