public BidirectionalDictionary(int capacity, IEqualityComparer <TKey> keyComparer, IEqualityComparer <TValue> valueComparer)
        {
            if (capacity < 0)
            {
                throw new ArgumentOutOfRangeException("capacity", capacity, "capacity cannot be less than 0");
            }

            this.keyComparer   = keyComparer ?? EqualityComparer <TKey> .Default;
            this.valueComparer = valueComparer ?? EqualityComparer <TValue> .Default;

            keysToValues = new Dictionary <TKey, TValue>(capacity, this.keyComparer);
            valuesToKeys = new Dictionary <TValue, TKey>(capacity, this.valueComparer);

            inverse = new BidirectionalDictionary <TValue, TKey>(this);
        }
        public BidirectionalDictionary(IReadOnlyDictionary <TKey, TValue> dictionary)
        {
            if (dictionary == null)
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            this.keyComparer   = keyComparer ?? EqualityComparer <TKey> .Default;
            this.valueComparer = valueComparer ?? EqualityComparer <TValue> .Default;

            this.keysToValues = new Dictionary <TKey, TValue> (dictionary.Count, this.keyComparer);
            this.valuesToKeys = new Dictionary <TValue, TKey> (dictionary.Count, this.valueComparer);

            this.inverse = new BidirectionalDictionary <TValue, TKey> (this);

            foreach (var kvp in dictionary)
            {
                this.keysToValues.Add(kvp.Key, kvp.Value);
                this.valuesToKeys.Add(kvp.Value, kvp.Key);
            }
        }