Skip to content

Decide on RSeq an Operator type structure #1

@busti

Description

@busti

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 into Insert(0, elem)
    • Insert(index, elem) can be broken down into Patch(index, Iterable(elem), 0)
    • Patch(index, other, replaced) can be broken down into MassUpdate(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 size of the RSeq is known.

    • Without knowledge about the current size of the RSeq it is impossible to break down Prepend into Insert(elem, index) because there is no information about what index to insert it at.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions