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

后端 未结 5 1501
闹比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:35

    While I have close to no idea how scala is implemented. LinkedLists should be avoided,though.

    They are inefficient on current hardware due to traverse them each Node practically leads to a cache miss. Cache misses are what governs nowadays performance.

提交回复
热议问题