<commit_before>//
//  HKLCMTimeUtils.swift
//
//  Created by <NAME> on 2014/12/19.
//

import CoreMedia

// MARK: Initialization
public extension CMTime {
    public init(value: Int64, _ timescale: Int = 1) {
        self = CMTimeMake(value, Int32(timescale))
    }
    public init(value: Int64, _ timescale: Int32 = 1) {
        self = CMTimeMake(value, timescale)
    }
    public init(seconds: Float64, preferredTimeScale: Int32 = 1_000_000_000) {
        self = CMTimeMakeWithSeconds(seconds, preferredTimeScale)
    }
    public init(seconds: Float, preferredTimeScale: Int32 = 1_000_000_000) {
        self = CMTime(seconds: Float64(seconds), preferredTimeScale: preferredTimeScale)
    }
}

// MARK: - Arithmetic Protocol

// MARK: Add
func + (left: CMTime, right: CMTime) -> CMTime {
    return CMTimeAdd(left, right)
}
func += (inout left: CMTime, right: CMTime) -> CMTime {
    left = left + right
    return left
}

// MARK: Subtract<commit_msg>Add a subset of FloatingPointType methods as CMTime extension.<commit_after>//
//  HKLCMTimeUtils.swift
//
//  Created by <NAME> on 2014/12/19.
//

import CoreMedia

// MARK: Initialization
public extension CMTime {
    public init(value: Int64, _ timescale: Int = 1) {
        self = CMTimeMake(value, Int32(timescale))
    }
    public init(value: Int64, _ timescale: Int32 = 1) {
        self = CMTimeMake(value, timescale)
    }
    public init(seconds: Float64, preferredTimeScale: Int32 = 1_000_000_000) {
        self = CMTimeMakeWithSeconds(seconds, preferredTimeScale)
    }
    public init(seconds: Float, preferredTimeScale: Int32 = 1_000_000_000) {
        self = CMTime(seconds: Float64(seconds), preferredTimeScale: preferredTimeScale)
    }
}

// MARK: - FloatingPointType Protocol (subset)
public extension CMTime /* : FloatingPointType */ {
    /// true iff self is negative
    var isSignMinus: Bool {
        if self == kCMTimePositiveInfinity { return false }
        if self == kCMTimeNegativeInfinity { return false }
        if (self.flags & .Valid).rawValue > 0 { return false }
        return (self.value < 0) ^ (self.timescale < 0)
    }

    /// true iff self is zero, subnormal, or normal (not infinity or NaN).
    var isZero: Bool {
        return self == kCMTimeZero
    }
}

// MARK: - Arithmetic Protocol

// MARK: Add
func + (left: CMTime, right: CMTime) -> CMTime {
    return CMTimeAdd(left, right)
}
func += (inout left: CMTime, right: CMTime) -> CMTime {
    left = left + right
    return left
}

// MARK: Subtract
{'fraction_non_alphanumeric': 0.11438820247110403, 'fraction_numerical': 0.037863690713431646, 'mean_word_length': 3.003189792663477, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, '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': '1074314', 'n_tokens_mistral': 893, 'n_tokens_neox': 790, 'n_words': 222}