<commit_before>// Snowflake
// Written in 2015 by <NAME> <<EMAIL>>
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

import ReactiveCocoa

public class UniqueTable<Key: Hashable, Value>
{
    /**
    Initializes a unique table.
    
    - parameter withCache: If `true`, unique values will be cached with `NSCache`. If `false`, they will be removed once
                           there are no strong references to a signal producer for the value's key. If this parameter
                           is omitted, values will not be used.
    */
    public init(withCache: Bool = false)
    {
        table = DeinitCallbackPropertyTable<Key, Value>(withCache: withCache)
    }
    
    /// The unique table.
    let table: DeinitCallbackPropertyTable<Key, Value>
    
    // MARK: - Updating Values
    
    /**
    Updates the value for a specified key.
    
    - parameter value: The new value.
    - parameter key:   The key to update.
    */
    public func updateValue(value: Value, forKey key: Key)
    {
        table.setValue(value, forKey: key)
    }
    
    // MARK: - Retrieving Values
    
    /**
    Returns the current value for a key, if any.
    
    - parameter key: The key.
    */
    public subscript(key: Key) -> Value?
    {<commit_msg>UniqueTable’s table can be private.<commit_after>// Snowflake
// Written in 2015 by <NAME> <<EMAIL>>
//
// To the extent possible under law, the author(s) have dedicated all copyright and
// related and neighboring rights to this software to the public domain worldwide.
// This software is distributed without any warranty.
//
// You should have received a copy of the CC0 Public Domain Dedication along with
// this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.

import ReactiveCocoa

public class UniqueTable<Key: Hashable, Value>
{
    /**
    Initializes a unique table.
    
    - parameter withCache: If `true`, unique values will be cached with `NSCache`. If `false`, they will be removed once
                           there are no strong references to a signal producer for the value's key. If this parameter
                           is omitted, values will not be used.
    */
    public init(withCache: Bool = false)
    {
        table = DeinitCallbackPropertyTable<Key, Value>(withCache: withCache)
    }
    
    /// The unique table.
    private let table: DeinitCallbackPropertyTable<Key, Value>
    
    // MARK: - Updating Values
    
    /**
    Updates the value for a specified key.
    
    - parameter value: The new value.
    - parameter key:   The key to update.
    */
    public func updateValue(value: Value, forKey key: Key)
    {
        table.setValue(value, forKey: key)
    }
    
    // MARK: - Retrieving Values
    
    /**
    Returns the current value for a key, if any.
    
    - parameter key: The key.
    */
    public subscript(key: Key) -> Value?
    {
{'fraction_non_alphanumeric': 0.08849009900990099, 'fraction_numerical': 0.004331683168316832, 'mean_word_length': 2.315897435897436, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '744731', 'n_tokens_mistral': 911, 'n_tokens_neox': 878, 'n_words': 361}