Why are Scala's `Lists` implemented as linked lists

后端 未结 5 1493
闹比i
闹比i 2021-02-19 05:49

I always thought that the benefit of linked lists was that you could add or remove items (especially not from the end) without having to copy lots of elements thanks to the beau

5条回答
  •  粉色の甜心
    2021-02-19 06:32

    scala.List is an alias for scala.collection.immutable.List. It is but one of many concrete collection implementations.

    If you're coming from a Java background, equate java.util.List to scala.collection.mutable.Buffer, not to scala.List.

    You can get an overview of the structure of the collections library in the Scala 2.8 Collections Overview.. Here you'll find many other concrete implementations (both mutable and immutable).

提交回复
热议问题