<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace AKDK.Utilities
{
    /// <summary>
    ///     A directionary that supports 2-way lookups.
    /// </summary>
    public class TwoWayDictionary<T1, T2>
    {
        /// <summary>
        ///     Dictionary to support forward-lookup.
        /// </summary>
        readonly Dictionary<T1, T2> _forwardDictionary = new Dictionary<T1, T2>();

        /// <summary>
        ///     Dictionary to support reverse-lookup.
        /// </summary>
        readonly Dictionary<T2, T1> _reverseDictionary = new Dictionary<T2, T1>();

        /// <summary>
        ///     Create a new <see cref="TwoWayDictionary{T1, T2}"/>.
        /// </summary>
        public TwoWayDictionary()
        {
            Forward = new DictionariesWrapper<T1, T2>(_forwardDictionary, _reverseDictionary);
            Reverse = new DictionariesWrapper<T2, T1>(_reverseDictionary, _forwardDictionary);
        }

        /// <summary>
        ///     Create a new <see cref="TwoWayDictionary{T1, T2}"/> containing the specified items.
        /// </summary>
        /// <param name="items">
        ///     A sequence of <see cref="KeyValuePair{TKey, TValue}"/>s to add to the <see cref="TwoWayDictionary{T1, T2}"/>.
        /// </param>
        public TwoWayDictionary(IEnumerable<KeyValuePair<T1, T2>> items)
        {
            if (items == null)
                throw new ArgumentNullException(nameof(items));

            foreach (KeyValuePair<T1, T2> item in items)
                Add(item.Key, item.Value);
        }

        /// <summary>
        ///     Dictionary access from <typeparamref name="T1"/> to <typeparamref name="T2"/>.
        /// </summary>
        public IDictionary<T1, T2> Forward { get; }

        /// <summary>
        ///     Dictionary access from <typeparamref name="T2"/> to <typeparamref name="T1"/>.
        /// </summary>
        public IDictionary<T2, T1> Reverse { get; }

        /// <summary>
        ///     Get or set the specified value.
        /// </summary>
        /// <param name="key">
        ///     The value's associated key.<commit_msg>Additional constructors for TwoWayDictionary.<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace AKDK.Utilities
{
    /// <summary>
    ///     A directionary that supports 2-way lookups.
    /// </summary>
    public class TwoWayDictionary<T1, T2>
    {
        /// <summary>
        ///     Dictionary to support forward-lookup.
        /// </summary>
        readonly Dictionary<T1, T2> _forwardDictionary = new Dictionary<T1, T2>();

        /// <summary>
        ///     Dictionary to support reverse-lookup.
        /// </summary>
        readonly Dictionary<T2, T1> _reverseDictionary = new Dictionary<T2, T1>();

        /// <summary>
        ///     Create a new <see cref="TwoWayDictionary{T1, T2}"/>.
        /// </summary>
        public TwoWayDictionary()
        {
            Forward = new DictionariesWrapper<T1, T2>(_forwardDictionary, _reverseDictionary);
            Reverse = new DictionariesWrapper<T2, T1>(_reverseDictionary, _forwardDictionary);
        }

        /// <summary>
        ///     Create a new <see cref="TwoWayDictionary{T1, T2}"/> by copying the items in the specified <see cref="TwoWayDictionary{T1, T2}"/>.
        /// </summary>
        /// <param name="twoWayDictionary">
        ///     The <see cref="TwoWayDictionary{T1, T2}"/> to copy.
        /// </param>
        public TwoWayDictionary(TwoWayDictionary<T1, T2> twoWayDictionary)
        {
            if (twoWayDictionary == null)
                throw new ArgumentNullException(nameof(twoWayDictionary));

            foreach (var item in twoWayDictionary._forwardDictionary)
                _forwardDictionary.Add(item.Key, item.Value);

            foreach (var item in twoWayDictionary._reverseDictionary)
                _reverseDictionary.Add(item.Key, item.Value);
        }

        /// <summary>
        ///     Create a new <see cref="TwoWayDictionary{T1, T2}"/> containing the specified items.
        /// </summary>
        /// <param name="items">
        ///     A sequence of <see cref="KeyValuePair{TKey, TValue}"/>s to add to the <see cref="TwoWayDictionary{T1, T2}"/>.
        /// </param>
        public TwoWayDictionary(IEnumerable<KeyValuePair<T2, T1>> items)
        {
            if (items == null)
                throw new ArgumentNullException(nameof(items));

            foreach (KeyValuePair<T2, T1> item in items)
                Add(item.Key, item.Value);
        }

        /// <summary>
        ///     Create a new <see cref="TwoWayDictionary{T1, T2}"/> containing the specified items.
        /// </summary>
        /// <param name="items">
        ///     A sequence of <see cref="KeyValuePair{TKey, TValue}"/>s to add to the <see cref="TwoWayDictionary{T1, T2}"/>.
        /// </param>
        public TwoWayDictionary(IEnumerable<KeyValuePair<T1, T2>> items)
        {
            if (items == null)
                throw new ArgumentNullException(nameof(items));

            foreach (KeyValuePair<T1, T2> item in items)
                Add(item.Key, item.Value);
        }

        /// <summary>
        ///     Dictionary access from <typeparamref name="T1"/> to <typeparamref name="T2"/>.
        /// </summary>
        public IDictionary<T1, T2> Forward { get; }

        /// <summary>
        ///     Dictionary access from <typeparamref name="T2"/> to <typeparamref name="T1"/>.
        /// </summary>
        public IDictionary<T2, T1> Reverse { get; }

        /// <summary>
        ///     Get or set the specified value.
        /// </summary>
        /// <param name="key">
        ///     The value's associated key.
{'fraction_non_alphanumeric': 0.13984077535479406, 'fraction_numerical': 0.014191761855313257, 'mean_word_length': 1.8880559720139931, 'pattern_counts': {'":': 0, '<': 99, '<?xml version=': 0, '>': 99, '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': '396372', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1588, 'n_words': 411}