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

            dictionary.Add(1, 'a', "pesho");
            dictionary.Add(2, 'b', "gosho");
            dictionary.Add(1, 'c', "ivancho");
            dictionary.Add(3, 'c', "mariika");

            // searching by first key
            var firstKey          = 1;
            var resultsByFirstKey = dictionary.Search(firstKey);

            Console.WriteLine("All values with first key: {0}", firstKey);
            foreach (var value in resultsByFirstKey)
            {
                Console.WriteLine(value);
            }

            // searching by second key
            var secondKey          = 'c';
            var resultsBySecondKey = dictionary.Search(secondKey);

            Console.WriteLine("All values with second key: {0}", secondKey);
            foreach (var value in resultsBySecondKey)
            {
                Console.WriteLine(value);
            }

            // searching by both keys
            var resultsByBothKeys = dictionary.Search(firstKey, secondKey);

            Console.WriteLine("All values with first key {0} and second key {1}", firstKey, secondKey);
            foreach (var value in resultsByBothKeys)
            {
                Console.WriteLine(value);
            }
        }
        public static void Main(string[] args)
        {
            BiDictionary <int, string, string> numbersDictionary = new BiDictionary <int, string, string>();

            numbersDictionary.Add(4, "IV", "Four");
            numbersDictionary.Add(4, "IV", "Chetiri");
            numbersDictionary.Add(4, "IV", "Vier");
            numbersDictionary.Add(4, "IV", "Quatro");
            numbersDictionary.Add(4, "IV", "Shi");

            Console.WriteLine(numbersDictionary.ContainsKey1(4));
            Console.WriteLine(numbersDictionary.ContainsKey2("IV"));
            Console.WriteLine(numbersDictionary.ContainsKey1andKey2(4, "IV"));
            Console.WriteLine(numbersDictionary.ContainsKey1(43));

            //var numberFourWords = numbersDictionary[4];
            //var numberFourWords = numbersDictionary["IV"];
            var numberFourWords = numbersDictionary[4, "IV"];

            foreach (var word in numberFourWords)
            {
                Console.WriteLine(word);
            }
        }
Пример #3
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));
        }
Пример #4
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));
        }