-
Notifications
You must be signed in to change notification settings - Fork 0
Description
There are several different approaches to structuring the RSeq operator types. The current implementation is rather verbose, it currently individually defines the following operations:
case class Append(elem: A)
case class Prepend(elem: A)
case class Insert(index: Int, elem: A)
case class Remove(index: Int)
case class RemoveElem(elem: A)
case class Update(index: Int, elem: A)
case class Combined(indexRemoval: Int, indexInsertion: Int, elem: A)
case class AppendAll(elems: IterableOnce[A])
case class PrependAll(elems: IterableOnce[A])
case class InsertAll(index: Int, elems: IterableOnce[A])
case class RemoveAll(index: Int, count: Int)
case class RemoveAllElems(elems: IterableOnce[A])
case class Patch(index: Int, other: IterableOnce[A], replaced: Int)
case class MassUpdate(indicesRemoved: IterableOnce[Int], insertions: IterableOnce[(Int, A)])-
Some of these operations can be broken down into other operations, without any further information.
Prepend(elem)can be broken down intoInsert(0, elem)Insert(index, elem)can be broken down intoPatch(index, Iterable(elem), 0)Patch(index, other, replaced) can be broken down intoMassUpdate(index to replaced, other.zipWithIndex.map((elem, index) => (index, elem)))`- etc.
-
All of these Operations can be broken down into a single operation when the
sizeof theRSeqis known.- Without knowledge about the current
sizeof theRSeqit is impossible to break downPrependintoInsert(elem, index)because there is no information about what index to insert it at.
- Without knowledge about the current
So Theoretically, VBuffer could have an internal stream of verbose operations and break each of these down into a MassUpdate using a scan operator on the stream to track the size of the virtual collection.
However, MassUpdate contains two distinct collections. It has to be determined how the efficiency of this general type compares to using more specialized, but verbose types.