Changeset

public struct Changeset<Collection> where Collection : Collection

A set of changes in the sectioned collection.

Changes to the section of the linear collection should be empty.

Notice that the value of the changes represents offsets of collection not index. Since offsets are unordered, order is ignored when comparing two Changesets.

  • The collection after changed.

    Declaration

    Swift

    public var data: Collection
  • The offsets of deleted sections.

    Declaration

    Swift

    public var sectionDeleted: [Int]
  • The offsets of inserted sections.

    Declaration

    Swift

    public var sectionInserted: [Int]
  • The offsets of updated sections.

    Declaration

    Swift

    public var sectionUpdated: [Int]
  • The pairs of source and target offset of moved sections.

    Declaration

    Swift

    public var sectionMoved: [(source: Int, target: Int)]
  • The paths of deleted elements.

    Declaration

    Swift

    public var elementDeleted: [ElementPath]
  • The paths of inserted elements.

    Declaration

    Swift

    public var elementInserted: [ElementPath]
  • The paths of updated elements.

    Declaration

    Swift

    public var elementUpdated: [ElementPath]
  • The pairs of source and target path of moved elements.

    Declaration

    Swift

    public var elementMoved: [(source: ElementPath, target: ElementPath)]
  • Creates a new Changeset.

    Declaration

    Swift

    @inlinable
    public init(
        data: Collection,
        sectionDeleted: [Int] = [],
        sectionInserted: [Int] = [],
        sectionUpdated: [Int] = [],
        sectionMoved: [(source: Int, target: Int)] = [],
        elementDeleted: [ElementPath] = [],
        elementInserted: [ElementPath] = [],
        elementUpdated: [ElementPath] = [],
        elementMoved: [(source: ElementPath, target: ElementPath)] = []
        )

    Parameters

    data

    The collection after changed.

    sectionDeleted

    The offsets of deleted sections.

    sectionInserted

    The offsets of inserted sections.

    sectionUpdated

    The offsets of updated sections.

    sectionMoved

    The pairs of source and target offset of moved sections.

    elementDeleted

    The paths of deleted elements.

    elementInserted

    The paths of inserted elements.

    elementUpdated

    The paths of updated elements.

    elementMoved

    The pairs of source and target path of moved elements.

  • The number of section changes.

    Declaration

    Swift

    @inlinable
    var sectionChangeCount: Int { get }
  • The number of element changes.

    Declaration

    Swift

    @inlinable
    var elementChangeCount: Int { get }
  • The number of all changes.

    Declaration

    Swift

    @inlinable
    var changeCount: Int { get }
  • A Boolean value indicating whether has section changes.

    Declaration

    Swift

    @inlinable
    var hasSectionChanges: Bool { get }
  • A Boolean value indicating whether has element changes.

    Declaration

    Swift

    @inlinable
    var hasElementChanges: Bool { get }
  • A Boolean value indicating whether has changes.

    Declaration

    Swift

    @inlinable
    var hasChanges: Bool { get }
  • Declaration

    Swift

    public static func == (lhs: Changeset, rhs: Changeset) -> Bool
  • Declaration

    Swift

    public var debugDescription: String { get }