2

A LinkedList is needed for a custom LRU implementation. When looking at the source we see:

@deprecated("Low-level linked lists are deprecated 
   due to idiosyncrasies in interface and incomplete features.", "2.11.0")
class LinkedList[A]() extends AbstractSeq[A]
                     with LinearSeq[A]
                     with GenericTraversableTemplate[A, LinkedList]
                     with LinkedListLike[A, LinkedList[A]]
                     with Serializable {

So then what is the recommended alternative (none mentioned here..). Do we fall back to the java.util.LinkedList? I am guessing there were a better option ..

Update The specific characteristic of LinkedList that is needed is the ability to access an individual entry on O(1) in order to insert/remove elements in the list efficiently. This would require that a LinkedListEntry (or Node or similar ..) reference be exposed and returned upon creation of new element in the list. It appears none of the available implementations - including java.util.LinkedList - are suitable.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
  • `List` is a linked list, and very standard... why not use that? – dhg Oct 29 '15 at 17:50
  • @dhg that's true - I forget that scala uses linkedList (instead of ArrayList) as the default. Therefore Vector/IndexedSequence is often better choice for general purpose. I am looking at the List impl now to see if meets my needs. – WestCoastProjects Oct 29 '15 at 17:56
  • @dhg I am updating the OP to explain why the default ListBuffer will not suit my needs. – WestCoastProjects Oct 29 '15 at 18:00

1 Answers1

3

Probably LinkedHashMap may fit better than others, but:

there is spray-caching which is a really good implemantation and they are using something called ConcurrentLinkedHashMap which is better for using with Scala as it provides high-performance concurrency.

Hüseyin Zengin
  • 1,216
  • 11
  • 23