コード例 #1
0
            /// <summary>
            /// Verifica se existe a chave informada.
            /// </summary>
            /// <param name="key"></param>
            /// <returns></returns>
            public bool ContainsKey(object key)
            {
                var item  = new SortedList2Item(key, null);
                var index = _items.BinarySearch(item, _comparer);

                return(index >= 0);
            }
コード例 #2
0
 /// <summary>
 /// Recupera as posição pela chave informada.
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public List <int> this[object key]
 {
     get
     {
         var item  = new SortedList2Item(key, null);
         var index = _items.BinarySearch(item, _comparer);
         if (index >= 0)
         {
             return(_items[index].Indexes);
         }
         throw new IndexNotFoundException((key ?? "").ToString());
     }
     set
     {
         var item  = new SortedList2Item(key, null);
         var index = _items.BinarySearch(item, _comparer);
         if (index >= 0)
         {
             _items[index].Indexes = value;
         }
         else
         {
             _items.Add(new SortedList2Item(key, value));
         }
     }
 }