<commit_before>// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

import CoreFoundation

public struct _NSRange {
    public var location: Int
    public var length: Int
    public init() {
        location = 0
        length = 0
    }
    
    public init(location: Int, length: Int) {
        self.location = location
        self.length = length
    }
    
    internal init(_ range: CFRange) {
        location = range.location == kCFNotFound ? NSNotFound : range.location
        length = range.length
    }
}

extension CFRange {
    internal init(_ range: NSRange) {
        location = range.location == NSNotFound ? kCFNotFound : range.location
        length = range.length
    }
}

extension _NSRange {
    public init(_ x: Range<Int>) {
        if let start = x.first {
            if let end = x.last {
                self.init(location: start, length: end - start + 1)
                return
            }
        }
        self.init(location: 0, length: 0)
    }
    
    @warn_unused_result
    public func toRange() -> Range<Int>? {
        return Range<Int>(start: location, end: location + length)
    }
}

public typealias NSRange = _NSRange

public typealias NSRangePointer = UnsafeMutablePointer<NSRange>

public func NSMakeRange(loc: Int, _ len: Int) -> NSRange {
    return NSRange(location: loc, length: len)
}

public func NSMaxRange(range: NSRange) -> Int {
    return range.location + range.length
}

public func NSLocationInRange(loc: Int, _ range: NSRange) -> Bool {<commit_msg>Update extension to NSRange to be congruent with the swift stdlib overlay extension<commit_after>// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

import CoreFoundation

public struct _NSRange {
    public var location: Int
    public var length: Int
    public init() {
        location = 0
        length = 0
    }
    
    public init(location: Int, length: Int) {
        self.location = location
        self.length = length
    }
    
    internal init(_ range: CFRange) {
        location = range.location == kCFNotFound ? NSNotFound : range.location
        length = range.length
    }
}

extension CFRange {
    internal init(_ range: NSRange) {
        location = range.location == NSNotFound ? kCFNotFound : range.location
        length = range.length
    }
}

public typealias NSRange = _NSRange

extension NSRange {
    public init(_ x: Range<Int>) {
        location = x.startIndex
        length = x.count
    }
    
    @warn_unused_result
    public func toRange() -> Range<Int>? {
        if location == NSNotFound { return nil }
        return Range(start: location, end: location + length)
    }
}

public typealias NSRangePointer = UnsafeMutablePointer<NSRange>

public func NSMakeRange(loc: Int, _ len: Int) -> NSRange {
    return NSRange(location: loc, length: len)
}

public func NSMaxRange(range: NSRange) -> Int {
    return range.location + range.length
}

public func NSLocationInRange(loc: Int, _ range: NSRange) -> Bool {
{'fraction_non_alphanumeric': 0.09254066180594504, 'fraction_numerical': 0.007571508693213685, 'mean_word_length': 2.6066734074823055, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 18, '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': '3185049', 'n_tokens_mistral': 1037, 'n_tokens_neox': 999, 'n_words': 340}