Example #1
0
        public virtual TValue this[[NotNull] TKey key]
        {
            get
            {
                return(Base[key]);
            }
            set
            {
                if (key is null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                if (value is null)
                {
                    throw new ArgumentNullException(nameof(value));
                }

                Boolean valueRemoved = Reversed.Remove(value, out TKey rKey);
                Boolean keyRemoved   = Base.Remove(key, out TValue rValue);
                if (valueRemoved)
                {
                    Base.Remove(rKey);
                }
                if (keyRemoved)
                {
                    Reversed.Remove(rValue);
                }

                Base[key]       = value;
                Reversed[value] = key;
            }
        }
Example #2
0
        public virtual Boolean Remove([NotNull] TKey key, [NotNull] TValue value)
        {
            if (!Contains(key, value))
            {
                return(false);
            }

            Boolean removed = Base.Remove(key);

            if (removed ^ Reversed.Remove(value))
            {
                throw new CollectionSyncException();
            }

            return(removed);
        }
Example #3
0
 public ImmutableMap <TKey, TValue> Remove(TKey key, TValue value)
 {
     return(new ImmutableMap <TKey, TValue>(Base.Remove(key), Reversed.Remove(value)));
 }
Example #4
0
 public ImmutableMap <TKey, TValue> RemoveByValue(TValue key)
 {
     return(Reversed.ContainsKey(key) ? new ImmutableMap <TKey, TValue>(Base.Remove(Reversed[key]), Reversed.Remove(key)) : this);
 }
Example #5
0
 public ImmutableMap <TKey, TValue> Remove(TKey key)
 {
     return(Base.ContainsKey(key) ? new ImmutableMap <TKey, TValue>(Base.Remove(key), Reversed.Remove(Base[key])) : this);
 }