예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
                    }
                }
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
 public void Add(T t, T2 t2)
 {
     Forward.Add(t, t2);
     Reverse.Add(t2, t);
 }
예제 #5
0
 public void Add(T1 t1, T2 t2)
 {
     Forward.Add(t1, t2);
     Reverse.Add(t2, t1);
 }
예제 #6
0
 public void Add(T1 key, T2 value)
 {
     Forward.Add(key, value);
     Reverse.Add(value, key);
 }
예제 #7
0
 public void Add(KeyValuePair <V, K> item)
 {
     Reverse.Add(item.Key, item.Value);
     Forward.Add(item.Value, item.Key);
 }
예제 #8
0
 public void Add(KeyValuePair <K, V> item)
 {
     Forward.Add(item.Key, item.Value);
     Reverse.Add(item.Value, item.Key);
 }
예제 #9
0
 public void Add(V key, K value)
 {
     Reverse.Add(key, value);
     Forward.Add(value, key);
 }
예제 #10
0
 public void Add(K key, V value)
 {
     Forward.Add(key, value);
     Reverse.Add(value, key);
 }
예제 #11
0
 /// <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);