Example #1
0
        public void Add(T first, T second)
        {
            Dictionary <T, int> InnerMap;

            if (!Chain.ContainsKey(first))
            {
                InnerMap = new Dictionary <T, int>();
                InnerMap.Add(second, 0);
                Chain.Add(first, InnerMap);
            }
            else
            {
                InnerMap = Chain[first];
            }

            if (!InnerMap.ContainsKey(second))
            {
                InnerMap.Add(second, 0);
            }

            int weight = InnerMap[second];

            InnerMap.Remove(second);
            InnerMap.Add(second, weight + 1);
        }
        /// <summary>
        /// 지정한 요소를 가지고 있는지 확인합니다.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool Contains(KeyValuePair <TKey, ICollection <TValue> > item)
        {
            if (item.Value.IsEmptySequence())
            {
                return(false);
            }

            if (InnerMap.ContainsKey(item.Key) == false)
            {
                return(false);
            }

            lock (_syncLock) {
                var bag = InnerMap[item.Key];
                return(item.Value.All(v => bag.Contains(v)));
            }
        }
 /// <summary>
 /// 지정한 키를 가지고 있는가?
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public bool ContainsKey(TKey key)
 {
     return(InnerMap.ContainsKey(key));
 }