<commit_before>//
//  SortedListRunCounter.swift
//  RunsLister
//
//  Created by <NAME> on 9/28/17.
//  Copyright © 2017 Beepscore LLC. All rights reserved.
//

import Foundation

class SortedListRunCounter {

    /// - Parameters:
    ///   - intsSortedAscending: a list of integers sorted in increasing order
    ///   - value: the integer to search for
    /// - Returns: the count of occurrences of value. Returns 0 if not found.
    class func runCount(intsSortedAscending: [Int], value: Int) -> Int {

        guard let startIndex = intsSortedAscending.index(of: value) else {
            // value not in list
            return 0
        }

        // reversed() is lazy, returns an 'ReversedRandomAccessIndex<[Int]>' iterator
        // that can't be used directly in integer arithmetic
        // make a new array
        let intsSortedDescending = Array(intsSortedAscending.reversed())

        guard let reversedStartIndex = intsSortedDescending.index(of: value) else {
            return 0
        }

        let endIndex = (intsSortedAscending.count - 1) - reversedStartIndex
        return (endIndex - startIndex) + 1
    }

}<commit_msg>Revise comment.<commit_after>//
//  SortedListRunCounter.swift
//  RunsLister
//
//  Created by <NAME> on 9/28/17.
//  Copyright © 2017 Beepscore LLC. All rights reserved.
//

import Foundation

class SortedListRunCounter {

    /// - Parameters:
    ///   - intsSortedAscending: a list of integers sorted in increasing order
    ///   - value: the integer to search for
    /// - Returns: the count of occurrences of value. Returns 0 if not found.
    class func runCount(intsSortedAscending: [Int], value: Int) -> Int {

        guard let startIndex = intsSortedAscending.index(of: value) else {
            // value not in list
            return 0
        }

        // reversed() is lazy, returns an 'ReversedRandomAccessIndex<[Int]>' iterator
        // that can't be used directly in integer arithmetic
        // instantiate a new array
        let intsSortedDescending = Array(intsSortedAscending.reversed())

        guard let reversedStartIndex = intsSortedDescending.index(of: value) else {
            return 0
        }

        let endIndex = (intsSortedAscending.count - 1) - reversedStartIndex
        return (endIndex - startIndex) + 1
    }

}
{'fraction_non_alphanumeric': 0.09460043196544277, 'fraction_numerical': 0.012095032397408207, 'mean_word_length': 2.294452347083926, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1671729', 'n_tokens_mistral': 719, 'n_tokens_neox': 642, 'n_words': 213}