Esempio n. 1
0
        public BijectiveMap(
            BijectiveMap <TKey, TValue> bijectiveMap,
            IEqualityComparer <TKey> keyComparer,
            IEqualityComparer <TValue> valueComparer)
        {
            if (bijectiveMap is null)
            {
                throw new ArgumentNullException(nameof(bijectiveMap));
            }

            KeyDictionary = new Dictionary <TKey, TValue>(
                bijectiveMap.KeyDictionary,
                keyComparer);

            ValueDictionary = new Dictionary <TValue, TKey>(
                bijectiveMap.ValueDictionary,
                valueComparer);

            KeyComparer = keyComparer ??
                          EqualityComparer <TKey> .Default;

            ValueComparer = ValueComparer ??
                            EqualityComparer <TValue> .Default;

            Reverse = new BijectiveMap <TValue, TKey>(this);
        }
Esempio n. 2
0
        public BijectiveMap(
            int capacity,
            IEqualityComparer <TKey> keyComparer,
            IEqualityComparer <TValue> valueComparer)
        {
            KeyDictionary = new Dictionary <TKey, TValue>(
                capacity,
                keyComparer);

            ValueDictionary = new Dictionary <TValue, TKey>(
                capacity,
                valueComparer);

            KeyComparer = keyComparer ??
                          EqualityComparer <TKey> .Default;

            ValueComparer = ValueComparer ??
                            EqualityComparer <TValue> .Default;

            Reverse = new BijectiveMap <TValue, TKey>(this);
        }
Esempio n. 3
0
 private BijectiveMap(BijectiveMap <TValue, TKey> reverse)
 {
     ValueDictionary = reverse.KeyDictionary;
     KeyDictionary   = reverse.ValueDictionary;
     Reverse         = reverse;
 }
Esempio n. 4
0
 public BijectiveMap(BijectiveMap <TKey, TValue> bijectiveMap)
     : this(bijectiveMap, null, null)
 {
 }