public static void Main()
        {
            var biDictionary = new BiDictionary<bool, int, string>();

            biDictionary.Add(true, 18, "Ivan Petrov");
            biDictionary.Add(false, 18, "Gergana Mihova");
            biDictionary.Add(true, 30, "Petkan Iliev");
            biDictionary.Add(false, 25, "Ani Petrova");
            biDictionary.Add(true, 45, "Georgi Ivanov");
            biDictionary.Add(true, 45, "Pesho Goshov");
            biDictionary.Add(true, 45, "Miho Mihov");
            biDictionary.Add(false, 28, "Petranka Petrova");
            biDictionary.Add(false, 28, "Ivanka Ivanova");
            biDictionary.Add(false, 28, "Pepa Petrova");

            // all men
            Console.WriteLine(biDictionary.FindByFirstKey(true));

            // all 45 years old
            Console.WriteLine(biDictionary.FindBySecondKey(45));

            // all women 28 years old
            Console.WriteLine(biDictionary.FindByBothKeys(false, 28));

            // all 50 years old men
            Console.WriteLine(biDictionary.FindByBothKeys(true, 50)); // empty collection !!!
        }
示例#2
0
    static void Main()
    {
        BiDictionary <string, string, string> dictionary = new BiDictionary <string, string, string>();

        dictionary.Add("Sofia", "man", "Ivo Ivanov");
        dictionary.Add("Sofia", "woman", "Maria Ivanova");
        dictionary.Add("Plovdiv", "man", "Peter Petrov");
        dictionary.Add("Plovdiv", "woman", "Lili Georgieva");


        var fromSofia = dictionary.FindByFistKey("Sofia");

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

        var manGender = dictionary.FindBySecondKey("man");

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

        var manFromPlovdiv = dictionary.FindByBothKeys("Plovdiv", "man");

        foreach (var item in manFromPlovdiv)
        {
            Console.WriteLine(item);
        }
    }
        public static void Main()
        {
            var biDict = new BiDictionary<string, string, List<int>>();

            biDict.Add("Ivan", "DSA", new List<int>() { 100, 20, 30 });
            biDict.Add("Pesho", "HQC", new List<int>() { 10, 40, 25 });
            biDict.Add("Gosho", "DSA", new List<int>() { 55, 66, 77 });
            biDict.Add("Gosho", "HQC", new List<int>() { 5, 6, 7 });

            Console.WriteLine("Searching Pesho's scores");
            var result1 = biDict.FindByFirstKey("Pesho");
            foreach (var item in result1)
            {
                Console.WriteLine(string.Join(", ", item));
            }

            Console.WriteLine("--------------------------------");
            Console.WriteLine("Searching for all scores in DSA");
            var result2 = biDict.FindBySecondKey("DSA");
            foreach (var item in result2)
            {
                Console.WriteLine(string.Join(", ", item));
            }

            Console.WriteLine("--------------------------------");
            Console.WriteLine("Searching for DSA's scores of Gosho");
            var result3 = biDict.FindByBothKeys("Gosho", "DSA");
            foreach (var item in result3)
            {
                Console.WriteLine(string.Join(", ", item));
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            BiDictionary<string, string, string> dictionary = new BiDictionary<string, string, string>();
            dictionary.Add("Sofia", "man", "Ivo Ivanov");
            dictionary.Add("Sofia", "woman", "Maria Ivanova");
            dictionary.Add("Plovdiv", "man", "Peter Petrov");
            dictionary.Add("Plovdiv", "woman", "Lili Georgieva");
            
            Console.WriteLine("\nAll from Sofia");
            var fromSofia = dictionary.FindByFistKey("Sofia");
            foreach (var item in fromSofia)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nAll man");
            var manGender = dictionary.FindBySecondKey("man");
            foreach (var item in manGender)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine("\nAll Plovdiv and man");
            var manFromPlovdiv = dictionary.FindByBothKeys("Plovdiv", "man");
            foreach (var item in manFromPlovdiv)
            {
                Console.WriteLine(item);
            }
        }
示例#5
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);
            }
        }
示例#6
0
        static void Main(string[] args)
        {
            BiDictionary<string, string, string> dictionary = new BiDictionary<string, string, string>();
            dictionary.Add("Lovech", "man", "Georgi Georgiev");
            dictionary.Add("Lovech", "woman", "Nina Todorova");
            dictionary.Add("Lovech", "woman", "Martina Nikolova");
            dictionary.Add("Sofia", "woman", "Elizabet Sokolova");
            dictionary.Add("Lovech", "man", "Tosho Kyltyrista");

            Console.WriteLine("People from Lovech:");
            foreach (var item in dictionary.FindByFistKey("Lovech"))
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();
            Console.WriteLine("Girls:");
            var girls = dictionary.FindBySecondKey("woman");
            foreach (var girl in girls)
            {
                Console.WriteLine(girl);
            }

            Console.WriteLine();
            Console.WriteLine("Me and Tosho");
            foreach (var person in dictionary.FindByBothKeys("Lovech", "man"))
            {
                Console.WriteLine(person);
            }
        }
        static void Main(string[] args)
        {
            BiDictionary<string, string, string> dictionary = new BiDictionary<string, string, string>();
            dictionary.Add("Ivko", "mivko", "Ivko Mivko");
            dictionary.Add("Telerik", "Academy", "Telerik aka");
            dictionary.Add("Telerik", "asdf", "Peter Petrov");
            dictionary.Add("asdf", "Academy", "Dancho Danchev");


            var fromSofia = dictionary.FindByFistKey("Ivko");
            foreach (var item in fromSofia)
            {
                Console.WriteLine(item);
            }

            var manGender = dictionary.FindBySecondKey("asdf");
            foreach (var item in manGender)
            {
                Console.WriteLine(item);
            }

            var manFromPlovdiv = dictionary.FindByBothKeys("Telerik", "Academy");
            foreach (var item in manFromPlovdiv)
            {
                Console.WriteLine(item);
            }
        }
        public static void Main()
        {
            BiDictionary<string, string, Student> students = new BiDictionary<string, string, Student>();
            List<string> firstKeysTest = new List<string>();
            List<string> secondKeysTest = new List<string>();
            List<string> bothKeysTest = new List<string>();
            Random random = new Random();
            for (int i = 0; i < 10; i++)
            {
                var lengthFirstName = random.Next(2, 20);
                string firstName = GetRandomString(lengthFirstName, random);
                var lengthLastName = random.Next(2, 20);
                string lastName = GetRandomString(lengthLastName, random);
                Student student1 = new Student(firstName, lastName);
                students.Add(student1.FirstName, student1.LastName, student1);
                firstKeysTest.Add(student1.FirstName);
                secondKeysTest.Add(student1.LastName);
                bothKeysTest.Add(student1.FirstName + student1.LastName);
                if (i % 2 == 0)
                {
                    Student student2 = new Student(firstName, lastName);
                    students.Add(student2.FirstName, student2.LastName, student2);
                    firstKeysTest.Add(student2.FirstName);
                    secondKeysTest.Add(student2.LastName);
                    bothKeysTest.Add(student2.FirstName + student2.LastName);
                }
            }

            for (int i = 0; i < 10; i++)
            {
                var searchedFirstNameIndex = random.Next(0, firstKeysTest.Count);
                var studentsByFirstName = students.FindByFirstKey(firstKeysTest[searchedFirstNameIndex]);
                Console.WriteLine("New Search");
                Console.WriteLine("Students searched by first name:");
                foreach (var st in studentsByFirstName)
                {
                    Console.WriteLine("Student:" + st.FirstName + " " + st.LastName);
                }

                var searchedLastNameIndex = random.Next(0, secondKeysTest.Count);
                var studentsByLastName = students.FindBySecondKey(secondKeysTest[searchedLastNameIndex]);
                Console.WriteLine("Students searched by last name:");
                foreach (var st in studentsByLastName)
                {
                    Console.WriteLine("Student:" + st.FirstName + " " + st.LastName);
                }

                var studentsByBothNames = students.FindByBothKeys(firstKeysTest[i], secondKeysTest[i]);
                Console.WriteLine("Students searched by both names:");
                foreach (var st in studentsByBothNames)
                {
                    Console.WriteLine("Student: " + st.FirstName + " " + st.LastName);
                }

                Console.WriteLine();
            }
        }
示例#9
0
        public static void Main()
        {
            var dictionary = new BiDictionary<int, string, string>(true);
            dictionary.Add(1, "1", "value 1");
            dictionary.Add(2, "2", "value 2");
            dictionary.Add(3, "3", "value 3");
            dictionary.Add(3, "3", "value 3.1");

            Console.WriteLine(string.Join(", ", dictionary.FindByFirstKey(1)));
            Console.WriteLine(string.Join(", ", dictionary.FindBySecondKey("2")));
            Console.WriteLine(string.Join(", ", dictionary.FindByBothKeys(3, "3")));
        }
 static void Main(string[] args)
 {
     var distances = new BiDictionary<string, string, int>();
     distances.Add("Sofia", "Varna", 443);
     distances.Add("Sofia", "Varna", 468);
     distances.Add("Sofia", "Varna", 490);
     distances.Add("Sofia", "Plovdiv", 145);
     distances.Add("Sofia", "Bourgas", 383);
     distances.Add("Plovdiv", "Bourgas", 253);
     distances.Add("Plovdiv", "Bourgas", 292);
     distances.Add("Varna", "Bourgas", 292);
     var distancesFromSofia = distances.FindByFirstKey("Sofia"); // [443, 468, 490, 145, 383]
     var distancesToBourgas = distances.FindBySecoundKey("Bourgas"); // [383, 253, 292]
     var distancesPlovdivBourgas = distances.FindByBothKeys("Plovdiv", "Bourgas"); // [253, 292]
     var distancesRousseVarna = distances.FindByBothKeys("Rousse", "Varna"); // []
     var distancesSofiaVarna = distances.FindByBothKeys("Sofia", "Varna"); // [443, 468, 490]
     distances.Remove("Sofia", "Varna"); // true
     var distancesFromSofiaAgain = distances.FindByFirstKey("Sofia"); // [145, 383]
     var distancesToVarna = distances.FindBySecoundKey("Varna"); // []
     var distancesToVarn1a = distances.FindByFirstKey("Varna"); // []
     var distancesSofiaVarnaAgain = distances.FindByBothKeys("Sofia", "Varna"); // []
 }
示例#11
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));
        }
示例#12
0
        public static void Main()
        {
            var dict = new BiDictionary<int, int, string>(true);

            dict.Add(1, 2, "Pesho");
            dict.Add(1, 2, "Gosho");
            dict.Add(1, 3, "Mimi");
            dict.Add(1, 3, "Gimi");
            dict.Add(2, 3, "Dimi");
            dict.Remove(1, 3, "Gimi");

            for (int i = 0; i < 1000000; i++)
            {
                dict.Add(i+1, i+2, "Pesho"+i);
            }

            Console.WriteLine("Find by first key");
            dict.FindByFirstKey(1).ForEach(x => Console.WriteLine(x));
            Console.WriteLine("Find by second key");
            dict.FindBySecondKey(4).ForEach(x => Console.WriteLine(x));
            Console.WriteLine("Find by both keys");
            dict.FindByBothKeys(1, 3).ForEach(x => Console.WriteLine(x));
        }
    public static void Main()
    {
        BiDictionary<int, double, string> biDictionary = new BiDictionary<int, double, string>(true);
        biDictionary.Add(1, 1.1, "a");
        biDictionary.AddMany(2, 2.4, new string[] { "c", "d", "e" });
        biDictionary.Add(3, 3.3, "z");
        var firstFound = biDictionary.FindByFirstKey(2);
        foreach (var item in firstFound)
        {
            Console.WriteLine("{0} key {1} value", item.Key, item.Value);
        }

        var secondFound = biDictionary.FindBySecondKey(1.1);
        foreach (var item in secondFound)
        {
            Console.WriteLine("{0} key {1} value", item.Key, item.Value);
        }

        var bothFound = biDictionary.FindByBothKeys(3, 3.3);
        foreach (var item in bothFound)
        {
            Console.WriteLine("{0} key {1} value", item.Key, item.Value);
        }
    }