I’d like to write custom linear collection. Something like extended List in some specific cases (not for all parameter types).
Scala has complicated collection class hierarchy and I’m lost. What trait should I extend, what methods should I implement?
I’ve found comprehended tutorial for custom traversable implementation: http://daily-scala.blogspot.ru/2010/04/creating-custom-traversable.html.
And I’m searching for similar hints about implementing custom linear sequence.
It really isn’t that different from implementing a traverasable. There are only two abstract method on
LinearSeq, and three onLinearSeqLike, which you should also extend.However, as the doc for the latter makes clear, it is important that you override the following methods so they have an efficient implementation: