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 HrefLookup(string contents) : this() { var json = JsonConvert.DeserializeObject <dynamic>(contents); foreach (dynamic category in json.categories) { var url = category.pageURL.ToString(); var id = category.id.ToString(); if (!string.IsNullOrEmpty(url) && !string.IsNullOrEmpty(id)) { var href = string.Format("{0}{1}", (url != null && !url.StartsWith(Config.Params.HrefPrefix) ? Config.Params.HrefPrefix : string.Empty), url); if (Forward.Get(href) == null) { Forward.Add(href, id); } if (Reverse.Get(id) == null) { Reverse.Add(id, href); } } } }
public K this[V key] { get { return(Reverse[key]); } set { var tmpFwdKey = Reverse[key]; var tmpFwdVal = Forward[tmpFwdKey]; Forward.Remove(tmpFwdKey); Forward.Add(tmpFwdKey, tmpFwdVal); Reverse[key] = value; } }
public void Add(T t, T2 t2) { Forward.Add(t, t2); Reverse.Add(t2, t); }
public void Add(T1 t1, T2 t2) { Forward.Add(t1, t2); Reverse.Add(t2, t1); }
public void Add(T1 key, T2 value) { Forward.Add(key, value); Reverse.Add(value, key); }
public void Add(KeyValuePair <V, K> item) { Reverse.Add(item.Key, item.Value); Forward.Add(item.Value, item.Key); }
public void Add(KeyValuePair <K, V> item) { Forward.Add(item.Key, item.Value); Reverse.Add(item.Value, item.Key); }
public void Add(V key, K value) { Reverse.Add(key, value); Forward.Add(value, key); }
public void Add(K key, V value) { Forward.Add(key, value); Reverse.Add(value, key); }
/// <summary> /// Add a value to the dictionary with the specified key. /// </summary> /// <param name="key"> /// The key. /// </param> /// <param name="value"> /// The value. /// </param> public void Add(T1 key, T2 value) => Forward.Add(key, value);