Dwifft

public struct Dwifft

Namespace for the diff and apply functions.

  • Returns the sequence of DiffSteps required to transform one array into another.

    Declaration

    Swift

    public static func diff<Value: Equatable>(_ lhs: [Value], _ rhs: [Value]) -> [DiffStep<Value>]

    Parameters

    lhs

    an array

    rhs

    another, uh, array

    Return Value

    the series of transformations that, when applied to lhs, will yield rhs.

  • Applies a diff to an array. The following should always be true: Given x: [T], y: [T], Dwifft.apply(Dwifft.diff(x, y), toArray: x) == y

    Declaration

    Swift

    public static func apply<Value>(diff: [DiffStep<Value>], toArray lhs: [Value]) -> [Value]

    Parameters

    diff

    a diff, as computed by calling Dwifft.diff. Note that you be careful to not modify said diff before applying it, and to only apply it to the left hand side of a previous call to Dwifft.diff. If not, this can (and probably will) trigger an array out of bounds exception.

    lhs

    an array.

    Return Value

    lhs, transformed by diff.

  • Returns the sequence of SectionedDiffSteps required to transform one SectionedValues into another.

    Declaration

    Swift

    public static func diff<Section: Equatable, Value: Equatable>(lhs: SectionedValues<Section, Value>, rhs: SectionedValues<Section, Value>) -> [SectionedDiffStep<Section, Value>]

    Parameters

    lhs

    a SectionedValues

    rhs

    another, uh, SectionedValues

    Return Value

    the series of transformations that, when applied to lhs, will yield rhs.

  • Applies a diff to a SectionedValues. The following should always be true: Given x: SectionedValues<S,T>, y: SectionedValues<S,T>, Dwifft.apply(Dwifft.diff(lhs: x, rhs: y), toSectionedValues: x) == y

    Declaration

    Swift

    public static func apply<Section, Value>(diff: [SectionedDiffStep<Section, Value>], toSectionedValues lhs: SectionedValues<Section, Value>) -> SectionedValues<Section, Value>

    Parameters

    diff

    a diff, as computed by calling Dwifft.diff. Note that you be careful to not modify said diff before applying it, and to only apply it to the left hand side of a previous call to Dwifft.diff. If not, this can (and probably will) trigger an array out of bounds exception.

    lhs

    a SectionedValues.

    Return Value

    lhs, transformed by diff.