<commit_before>//
//  CollectionViewDataSource.swift
//  SwiftMVVMBinding
//
//  Created by <NAME> on 2015-11-18.
//  Copyright © 2015 theScore. All rights reserved.
//

import UIKit

extension UICollectionView: DataSourceView {
    public typealias CellView = UICollectionViewCell
    
    public func insertCells(indexPaths indexPaths: [NSIndexPath]) {
        insertItemsAtIndexPaths(indexPaths)
    }
    
    public func deleteCells(indexPaths indexPaths: [NSIndexPath]) {
        deleteItemsAtIndexPaths(indexPaths)
    }
    
    public func batchUpdates(updates: () -> Void) {
        performBatchUpdates(updates, completion: nil)
    }
    
    
    public func indexPathsForSelections() -> [NSIndexPath]? {
        return indexPathsForSelectedItems()
    }
    
    public func select(indexPath indexPath: NSIndexPath) {
        selectItemAtIndexPath(indexPath, animated: false, scrollPosition: .None)
    }
    
    public func deselect(indexPath indexPath: NSIndexPath) {
        deselectItemAtIndexPath(indexPath, animated: false)
    }
    
    
    public func dequeueCell(reuseIdentifier reuseIdentifier: String, indexPath: NSIndexPath) -> UICollectionViewCell {
        return dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath)
    }
}


public class CollectionViewDataSource<S: SubscribableType where S.ValueType: RangeReplaceableCollectionType, S.ValueType.Generator.Element: Equatable>: DataSource<S, UICollectionView>, UICollectionViewDataSource, UICollectionViewDelegate {
    
    public override init(subscribable: S, view: UICollectionView) {
        super.init(subscribable: subscribable, view: view)
    }
    
    //MARK: UICollectionViewDataSource
    
    public func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        return numberOfSections()
    }
    
    public func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return numberOfItems(section: section)
    }
    
    public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        return cellAtIndexPath(indexPath)
    }
    
    //MARK: UICollectionViewDelegate
    
    public func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        didSelect(indexPath: indexPath)
    }
    
    public func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {
        didDeselect(indexPath: indexPath)
    }
    
}<commit_msg>Collection view binding - support reordering<commit_after>//
//  CollectionViewDataSource.swift
//  SwiftMVVMBinding
//
//  Created by <NAME> on 2015-11-18.
//  Copyright © 2015 theScore. All rights reserved.
//

import UIKit

extension UICollectionView: DataSourceView {
    public typealias CellView = UICollectionViewCell
    
    public func insertCells(indexPaths indexPaths: [NSIndexPath]) {
        insertItemsAtIndexPaths(indexPaths)
    }
    
    public func deleteCells(indexPaths indexPaths: [NSIndexPath]) {
        deleteItemsAtIndexPaths(indexPaths)
    }
    
    public func batchUpdates(updates: () -> Void) {
        performBatchUpdates(updates, completion: nil)
    }
    
    
    public func indexPathsForSelections() -> [NSIndexPath]? {
        return indexPathsForSelectedItems()
    }
    
    public func select(indexPath indexPath: NSIndexPath) {
        selectItemAtIndexPath(indexPath, animated: false, scrollPosition: .None)
    }
    
    public func deselect(indexPath indexPath: NSIndexPath) {
        deselectItemAtIndexPath(indexPath, animated: false)
    }
    
    
    public func dequeueCell(reuseIdentifier reuseIdentifier: String, indexPath: NSIndexPath) -> UICollectionViewCell {
        return dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath)
    }
}


public class CollectionViewDataSource<S: SubscribableType where S.ValueType: RangeReplaceableCollectionType, S.ValueType.Generator.Element: Equatable>: DataSource<S, UICollectionView>, UICollectionViewDataSource, UICollectionViewDelegate {
    
    public override init(subscribable: S, view: UICollectionView) {
        super.init(subscribable: subscribable, view: view)
    }
    
    //MARK: UICollectionViewDataSource
    
    public func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
        return numberOfSections()
    }
    
    public func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return numberOfItems(section: section)
    }
    
    public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        return cellAtIndexPath(indexPath)
    }
    
    @available(iOS 9, *)
    public func collectionView(collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: NSIndexPath) -> Bool {
        return editable && allowsMoving
    }
    
    @available(iOS 9, *)
    public func collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
        move(source: sourceIndexPath, destination: destinationIndexPath)
    }
    
    //MARK: UICollectionViewDelegate
    
    public func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
        didSelect(indexPath: indexPath)
    }
    
    public func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) {
        didDeselect(indexPath: indexPath)
    }
    
}
{'fraction_non_alphanumeric': 0.07465825446898001, 'fraction_numerical': 0.004556607080266386, 'mean_word_length': 3.7837384744341995, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, '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': '2000746', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1584, 'n_words': 337}