I'm using the RingBuffer implementation mentioned in this answer, which inherits from IndexedSeq:
class RingBuffer[A](val index: Int, val data: IndexedSeq[A]) extends IndexedSeq[A] {
def shiftLeft = new RingBuffer((index + 1) % data.size, data)
def shiftRight = new RingBuffer((index + data.size - 1) % data.size, data)
def length = data.length
def apply(i: Int) = data((index + i) % data.size)
}
What I want to be able to do is this:
var rb = new RingBuffer(0, IndexedSeq(1, 2, 3))
rb = rb.updated(0, 4).shiftLeft
... but updated returns an IndexedSeq.
Should I override updated in the RingBuffer implementation? Or is there a different approach I should take?