 
 import UIKit
 
-public protocol DiffCalculator: class {
-    associatedtype S: Equatable
-    associatedtype T: Equatable
-    var rowsAndSections: SectionedValues<S, T> { get set }
-    func numberOfSections() -> Int
-    func value(forSection: Int) -> S
-    func numberOfObjects(inSection section: Int) -> Int
-    func value(atIndexPath indexPath: IndexPath) -> T
+class AbstractDiffCalculator<S: Equatable, T:Equatable> {
 
-    func processChanges(
-        newState: SectionedValues<S, T>,
-        diff: [DiffStep2D<S, T>]
-    )
+    init(initialRowsAndSections: SectionedValues<S, T>) {
+        self._rowsAndSections = initialRowsAndSections
+    }
 
-    func internalRowsAndSections() -> SectionedValues<S, T>
-}
-
-public extension DiffCalculator {
     public func numberOfSections() -> Int {
         return self.rowsAndSections.count
     }

        return self.rowsAndSections[indexPath.section].1[indexPath.row]
    }

    public var rowsAndSections : SectionedValues<S, T> {
        get {
            return internalRowsAndSections()
        }
        set {
            let oldRowsAndSections = rowsAndSections

    }
}

public class CollectionViewDiffCalculator<S: Equatable, T: Equatable> : AbstractDiffCalculator<S, T> {

    public weak var collectionView: UICollectionView?

    public init(collectionView: UICollectionView, initialRowsAndSections: SectionedValues<S, T> = SectionedValues()) {
        self.collectionView = collectionView
        super.init(initialRowsAndSections: initialRowsAndSections)
    }

    override func processChanges(newState: SectionedValues<S, T>, diff: [DiffStep2D<S, T>]) {
        guard let collectionView = self.collectionView else { return }
        self._rowsAndSections = newState
        collectionView.performBatchUpdates({
