public void Add(T1 t1, T2 t2) { t1 = GetIndex(t1); t2 = GetIndex(t2); if (Forward.ContainsKey(t1)) { return; } lock (_locker) { if (Forward.ContainsKey(t1)) { return; } _forward = _forward.Add(t1, t2); _reverse = _reverse.Add(GetIndex(t2), t1); var forward = new Indexer <T1, T2>(_forward); var reverse = new Indexer <T2, T1>(_reverse); Interlocked.Exchange(ref _forwardIndexer, forward); Interlocked.Exchange(ref _reverseIndexer, reverse); } }
void InternalAdd(T1 t1, T2 t2) { try { if (t1 == null || t2 == null) { throw new ArgumentException("Null key value", "Null value is not allowed."); } if (Forward.ContainsKey(t1) || Reverse.ContainsKey(t2)) { throw new System.ArgumentException("A pair with same item already exist!"); } else { Forward.Add(t1, t2); Reverse.Add(t2, t1); } } catch (Exception e) { // throw new System.Exception("BiMap: Unknow exception in Add()."); throw e; } }
public bool Contains(T1 key) { if (key == null) { throw new ArgumentException("Null key query", "Null is not allowed."); } return(Forward.ContainsKey(key)); }
#pragma warning restore CS8601 public bool ContainsKey(T1 key) => Forward.ContainsKey(key);
/// <summary> /// /// </summary> /// <param name="first"></param> /// <returns></returns> public IEnumerable <TSecond> GetByFirst(TFirst first) { return(Forward.ContainsKey(first) ? Forward[first] : EmptySecondList); }
public bool ContainsKey(T1 key) { ContainingCheck(key); return(Forward.ContainsKey(key)); }
public bool Contains(KeyValuePair <T2, T1> item) { return(((ICollection <KeyValuePair <T2, T1> >)Reverse).Contains(item) && Forward.ContainsKey(item.Value) && Forward[item.Value].Equals(item.Key)); }
public bool ContainsKey(K key) { return(Forward.ContainsKey(key)); }