<commit_before>//
//  Copyright © 2018 wczekalski. All rights reserved.

#if !os(watchOS)
import Foundation

struct NestedBatchUpdate {
    let itemDeletions: [IndexPath]
    let itemInsertions: [IndexPath]
    let itemMoves: [(from: IndexPath, to: IndexPath)]
    let sectionDeletions: IndexSet
    let sectionInsertions: IndexSet
    let sectionMoves: [(from: Int, to: Int)]

    init(
        diff: NestedExtendedDiff,
        indexPathTransform: (IndexPath) -> IndexPath = { $0 },
        sectionTransform: (Int) -> Int = { $0 }
        ) {
        var itemDeletions: [IndexPath] = []
        var itemInsertions: [IndexPath] = []
        var itemMoves: [(IndexPath, IndexPath)] = []
        var sectionDeletions: IndexSet = []
        var sectionInsertions: IndexSet = []
        var sectionMoves: [(from: Int, to: Int)] = []

        diff.forEach { element in
            switch element {
            case let .deleteElement(at, section):
                itemDeletions.append(indexPathTransform([section, at]))
            case let .insertElement(at, section):
                itemInsertions.append(indexPathTransform([section, at]))
            case let .moveElement(from, to):
                itemMoves.append((indexPathTransform([from.section, from.item]), indexPathTransform([to.section, to.item])))
            case let .deleteSection(at):
                sectionDeletions.insert(sectionTransform(at))
            case let .insertSection(at):
                sectionInsertions.insert(sectionTransform(at))
            case let .moveSection(move):
                sectionMoves.append((sectionTransform(move.from), sectionTransform(move.to)))
            }
        }

        self.itemInsertions = itemInsertions
        self.itemDeletions = itemDeletions
        self.itemMoves = itemMoves
        self.sectionMoves = sectionMoves
        self.sectionInsertions = sectionInsertions
        self.sectionDeletions = sectionDeletions
    }
}

#endif

<commit_msg>Make NestedBatchUpdate public<commit_after>//
//  Copyright © 2018 wczekalski. All rights reserved.

#if !os(watchOS)
import Foundation

public struct NestedBatchUpdate {
    public let itemDeletions: [IndexPath]
    public let itemInsertions: [IndexPath]
    public let itemMoves: [(from: IndexPath, to: IndexPath)]
    public let sectionDeletions: IndexSet
    public let sectionInsertions: IndexSet
    public let sectionMoves: [(from: Int, to: Int)]

    public init(
        diff: NestedExtendedDiff,
        indexPathTransform: (IndexPath) -> IndexPath = { $0 },
        sectionTransform: (Int) -> Int = { $0 }
        ) {
        var itemDeletions: [IndexPath] = []
        var itemInsertions: [IndexPath] = []
        var itemMoves: [(IndexPath, IndexPath)] = []
        var sectionDeletions: IndexSet = []
        var sectionInsertions: IndexSet = []
        var sectionMoves: [(from: Int, to: Int)] = []

        diff.forEach { element in
            switch element {
            case let .deleteElement(at, section):
                itemDeletions.append(indexPathTransform([section, at]))
            case let .insertElement(at, section):
                itemInsertions.append(indexPathTransform([section, at]))
            case let .moveElement(from, to):
                itemMoves.append((indexPathTransform([from.section, from.item]), indexPathTransform([to.section, to.item])))
            case let .deleteSection(at):
                sectionDeletions.insert(sectionTransform(at))
            case let .insertSection(at):
                sectionInsertions.insert(sectionTransform(at))
            case let .moveSection(move):
                sectionMoves.append((sectionTransform(move.from), sectionTransform(move.to)))
            }
        }

        self.itemInsertions = itemInsertions
        self.itemDeletions = itemDeletions
        self.itemMoves = itemMoves
        self.sectionMoves = sectionMoves
        self.sectionInsertions = sectionInsertions
        self.sectionDeletions = sectionDeletions
    }
}

#endif


{'fraction_non_alphanumeric': 0.10374064837905236, 'fraction_numerical': 0.0029925187032418953, 'mean_word_length': 2.503056768558952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2349960', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1086, 'n_words': 254}