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; } }
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); }
public ImmutableMap <TKey, TValue> Remove(TKey key, TValue value) { return(new ImmutableMap <TKey, TValue>(Base.Remove(key), Reversed.Remove(value))); }
public ImmutableMap <TKey, TValue> RemoveByValue(TValue key) { return(Reversed.ContainsKey(key) ? new ImmutableMap <TKey, TValue>(Base.Remove(Reversed[key]), Reversed.Remove(key)) : this); }
public ImmutableMap <TKey, TValue> Remove(TKey key) { return(Base.ContainsKey(key) ? new ImmutableMap <TKey, TValue>(Base.Remove(key), Reversed.Remove(Base[key])) : this); }