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
lhsan array
rhsanother, uh, array
Return Value
the series of transformations that, when applied to
lhs, will yieldrhs. -
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) == yDeclaration
Swift
public static func apply<Value>(diff: [DiffStep<Value>], toArray lhs: [Value]) -> [Value]Parameters
diffa 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 toDwifft.diff. If not, this can (and probably will) trigger an array out of bounds exception.lhsan array.
Return Value
lhs, transformed bydiff. -
Returns the sequence of
SectionedDiffSteps required to transform oneSectionedValuesinto another.Declaration
Swift
public static func diff<Section: Equatable, Value: Equatable>(lhs: SectionedValues<Section, Value>, rhs: SectionedValues<Section, Value>) -> [SectionedDiffStep<Section, Value>]Parameters
lhsa
SectionedValuesrhsanother, uh,
SectionedValuesReturn Value
the series of transformations that, when applied to
lhs, will yieldrhs. -
Applies a diff to a
SectionedValues. The following should always be true: Givenx: SectionedValues<S,T>, y: SectionedValues<S,T>,Dwifft.apply(Dwifft.diff(lhs: x, rhs: y), toSectionedValues: x) == yDeclaration
Swift
public static func apply<Section, Value>(diff: [SectionedDiffStep<Section, Value>], toSectionedValues lhs: SectionedValues<Section, Value>) -> SectionedValues<Section, Value>Parameters
diffa 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 toDwifft.diff. If not, this can (and probably will) trigger an array out of bounds exception.lhsa
SectionedValues.Return Value
lhs, transformed bydiff.
View on GitHub
Dwifft Struct Reference