I am new to Scala and still a little confused with my complex type system.
I am trying to solve the following problem. I want to create classes that are members of mutable doubly linked lists (and more complex data structures such as heaps). My goal, of course, is to remove objects from data structures at a constant time.
I developed the following symptom:
trait DLLMember { var next: DLLMember = this var prev: DLLMember = this ... }
with several additional methods for adding and removing an object from the list.
The problem is that when I am in my actual class, say:
class IntInDL(val v: Int) extends DLLMember
When parsing my list, IntInDL.next will return a DLLMember type instead of IntInDL, which I should use to extract the value: this is not nice ...
Is there a way to use the Scala type system to save my work?
source share