Why no immutable double linked list in Scala collections?

Looking at this question, where the questioner is interested in the first and last instances of some element in a List, it seems a more efficient solution would be to use a DoubleLinkedList that could search backwards from the end of the list. However there is only one implementation in the collections API and it's mutable.

Why is there no immutable version?

Answers


Because you would have to copy the whole list each time you want to make a change. With a normal linked list, you can at least prepend to the list without having to copy everything. And if you do want to copy everything on every change, you don't need a linked list for that. You can just use an immutable array.


Need Your Help

Link color/size in Weebly (CSS/HTML)

jquery html css weebly

So I'm trying to make a little image menu on weebly. The goal is pretty simple. There are a couple of images and when you hover over them, the background fades and the caption background changes co...

Could not find oauth1-0.4.1 in any of the sources

ruby-on-rails ruby-on-rails-3 oauth

I have developing my application w/ no problems for a couple of months now. Today as I was trying to create a model using rails g model ... I get the following message in my terminal window:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.