Exemplo n.º 1
0
        public void Add(TKey key, TValue value)
        {
            int idx = GetIdx(key);

            if (_subDict[idx] != null)
            {
                _subDict[idx].Add(key, value);
            }
            else
            {
                _subDict[idx] = new DictionaryMd <TKey, TValue>(_size, _sizeOrigin, key, value);
            }
            _count++;
        }
Exemplo n.º 2
0
        private void SetValueByKey(TKey key, TValue value)
        {
            if (_subDict == null)
            {
                _singleValue = value;
                return;
            }
            int idx = GetIdx(key);

            if (_subDict[idx] == null)
            {
                _subDict[idx] = new DictionaryMd <TKey, TValue>(_size, _sizeOrigin, key, value);
            }
            else
            {
                _subDict[idx].SetValueByKey(key, value);
            }
        }
Exemplo n.º 3
0
Arquivo: Program.cs Projeto: m5ba/ba
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World! Let's count.");
            IDictionary <int, string> dict = new DictionaryMd <int, string>(100);

            dict[9] = "nine";
            dict.Add(8, "eight");
            Console.WriteLine($"{dict[9]}");
            Console.WriteLine($"{dict[8]}");
            dict[9] = "NINE";
            Console.WriteLine($"{dict[9]}");
            Console.WriteLine($"{dict[8]}");
            try{
                dict.Add(9, "akward");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception: \n   '{e.GetType()}'\n   '{e.Message}'");
            }
            Console.WriteLine("Goodbye...");
        }