Пример #1
0
        public static void Main()
        {
            var multi = new BiDictionary <int, string, string>();

            multi.Add(1, "one", "firstElement");

            multi.Add(1, "two", "mixed");

            multi.Add(2, "two", "secondElement");

            Console.WriteLine("first key :");
            var result1 = multi.FindByFirstKey(1);

            foreach (var item in result1)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("second key :");
            var result2 = multi.FindBySecondKey("two");

            foreach (var item in result2)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("both keys :");
            var result3 = multi.FindByBothKeys(1, "two");

            foreach (var item in result3)
            {
                Console.WriteLine(item);
            }
        }
Пример #2
0
        public static void Main()
        {
            var biDict = new BiDictionary <string, int, string>();

            biDict.Add("key1", 1, "value11");
            biDict.Add("key1", 2, "value12");
            biDict.Add("key1", 3, "value13");
            biDict.Add("key2", 1, "value21");
            biDict.Add("key2", 2, "value22");
            biDict.Add("key2", 3, "value23");

            Console.WriteLine(biDict.FindByFirstKey("key1"));

            Console.WriteLine(biDict.FindBySecondKey(1));

            Console.WriteLine(biDict.FindByTwoKeys("key1", 3));
        }
Пример #3
0
        static void Main()
        {
            var dictionary = new BiDictionary <int, double, string>();

            dictionary.Add(1, 1.5, "mariq");
            dictionary.Add(3, 3.01, "GANCHO");
            dictionary.Add(1, 1.5, "pesho");
            dictionary.Add(2, 50.9, "gosho");
            dictionary.Add(2, 50.9, "drago");
            dictionary.Add(2, 50.9, "dragan");

            var byFirstKey = dictionary.FindByFirstKey(1);

            Console.WriteLine("search by first key: {0}", string.Join(", ", byFirstKey));

            var bySecondKey = dictionary.FindBySecondKey(3.01);

            Console.WriteLine("search by second key: {0}", string.Join(", ", bySecondKey));

            var byBothKeys = dictionary.FindByBothKeys(2, 50.9);

            Console.WriteLine("search by both keys: {0}", string.Join(", ", byBothKeys));
        }