Patch

final case class Patch[T](baseSize: Int, targetSize: Int, steps: ArraySeq[Step[T]])

A Patch encapsulates all information required to transform the base sequence into the target sequence.

A Patch encapsulates all information required to transform the base sequence into the target sequence.

In addition to the data of which elements need to be deleted and/or moved it also contains the actual elements that are to be inserted.

Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(base: IndexedSeq[T])(ct: ClassTag[T]): Either[Failure, ArraySeq[T]]

Applies this patch to the given base sequence, producing either the original target sequence or an error.

Applies this patch to the given base sequence, producing either the original target sequence or an error.

def isEmpty: Boolean

True if the patch is a NOP, i.e. doesn't affect the base at all when applied.

True if the patch is a NOP, i.e. doesn't affect the base at all when applied.

def sorted: Patch[T]

Returns an equivalent patch that has all its steps sorted by baseIx.

Returns an equivalent patch that has all its steps sorted by baseIx.

NOTE: The steps will be sorted anyway during application of the patch against a base sequence, so the steps can be held in any order in the Patch sequence. Pre-sorting of the steps as it is done here is therefore not required, but may be beneficial for presentation or other "normalization" processes.

def throwingApply(base: IndexedSeq[T])(ct: ClassTag[T]): ArraySeq[T]

Applies this patch to the given base sequence, producing the original target sequence or throwing a Patch.Failure.

Applies this patch to the given base sequence, producing the original target sequence or throwing a Patch.Failure.

def tryApply(base: IndexedSeq[T])(ct: ClassTag[T]): Try[ArraySeq[T]]

Applies this patch to the given base sequence, producing a Try instance holding either the original target sequence or a Patch.Failure.

Applies this patch to the given base sequence, producing a Try instance holding either the original target sequence or a Patch.Failure.

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product