static void Main(string[] args) { BiDictionary <string, int, string> bidictionary = new BiDictionary <string, int, string>(true); bidictionary.Add("Nasko", 4, "PHP"); bidictionary.Add("Joro", 3, "C#"); bidictionary.Add("Petar", 4, "C++"); bidictionary.Add("Raicho", 1, "PERL"); bidictionary.Add("Filip", 4, "Java"); bidictionary.Add("Sasho", 2, "Listy"); Console.WriteLine(string.Join(" ", bidictionary.GetByFirstKey("Joro"))); Console.WriteLine(string.Join(" ", bidictionary.GetBySecondKey(3))); Console.WriteLine(string.Join(" ", bidictionary.GetByFirstAndSecondKey("Sasho", 2))); Console.WriteLine(bidictionary.Count); bidictionary.RemoveByFirstKey("Raicho"); Console.WriteLine(bidictionary.Count); bidictionary.RemoveBySecondKey(2); Console.WriteLine(bidictionary.Count); bidictionary.RemoveByFirstAndSecondKey("Nasko", 4); }
static void Main() { var biDictionary = new BiDictionary <int, string, string>(); biDictionary.Add(5, "Blagoevgrad", "Petkan"); biDictionary.Add(5, "Sofia", "Ivan"); biDictionary.Add(5, "Sofia", "Stamat"); biDictionary.Add(55, "Varna", "Shisho bakshisho"); biDictionary.Add(5, "Pleven", "Maria"); biDictionary.Add(15, "Sofia", "Minka Svirkata"); Console.WriteLine(@"biDictionary.Add(5, ""Blagoevgrad"", ""Petkan""); biDictionary.Add(5, ""Sofia"", ""Ivan""); biDictionary.Add(5, ""Sofia"", ""Stamat""); biDictionary.Add(55, ""Varna"", ""Shisho bakshisho""); biDictionary.Add(5, ""Pleven"", ""Maria""); biDictionary.Add(15, ""Sofia"", ""Minka Svirkata""); "); var five = biDictionary.FindAllByFirstKey(5); PrintEnumerable(five, "biDictionary.FindAllByFirstKey(5)"); var sofia = biDictionary.FindAllBySecondKey("Sofia"); PrintEnumerable(sofia, "biDictionary.FindAllBySecondKey(\"Sofia\");"); var fiveSofia = biDictionary.FindAll(5, "Sofia"); PrintEnumerable(fiveSofia, "biDictionary.FindAll(5, \"Sofia\")"); }
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(); } }
public static void Main(string[] args) { // Demo BiDictionary <string, string, string> people = new BiDictionary <string, string, string>(); people.Add("Ivan", "Ivanov", "Front-Ender"); people.Add("Ivan", "Ivanov", ".NET Ninja"); people.Add("Ivan", "Georgiev", "Web Developer"); people.Add("Ivan", "Georgiev", "Student"); people.Add("Georgi", "Ivanov", "Driver"); people.Add("Georgi", "Georgiev", "Lawyer"); var jobsOfPeopleWithFirstNameIvan = people.FindByFirstKey("Ivan"); var jobsOfPeopleWithFirstNameGeorgi = people.FindByFirstKey("Georgi"); var jobsOfPeopleWithSecondNameIvanov = people.FindBySecondKey("Ivanov"); var jobsOfPeopleWithSecondNameGeorgiev = people.FindBySecondKey("Georgiev"); var jobsOfPeopleWithNameIvanIvanov = people.FindByBothKeys("Ivan", "Ivanov"); Console.WriteLine("The jobs of the people with first name Ivan"); foreach (var job in jobsOfPeopleWithFirstNameIvan) { Console.WriteLine(job); } Console.WriteLine("\nThe jobs of the people with first name Georgi"); foreach (var job in jobsOfPeopleWithFirstNameGeorgi) { Console.WriteLine(job); } Console.WriteLine("\nThe jobs of the people with second name Ivanov"); foreach (var job in jobsOfPeopleWithSecondNameIvanov) { Console.WriteLine(job); } Console.WriteLine("\nThe jobs of the people with second name Georgiev"); foreach (var job in jobsOfPeopleWithSecondNameGeorgiev) { Console.WriteLine(job); } Console.WriteLine("\nThe jobs of the people with full name Ivan Ivanov"); foreach (var job in jobsOfPeopleWithNameIvanIvanov) { Console.WriteLine(job); } }
public static void Main() { BiDictionary <string, string, int> persons = new BiDictionary <string, string, int>(); persons.Add("Nikolay", "Petrov", 21); persons.Add("Doncho", "Minkov", 25); persons.Add("Ivaylo", "Kenov", 25); persons.Add("Nikolay", "Kostov", 23); int[] ages = persons.FindByFirstKey("Nikolay"); Console.WriteLine(string.Join(", ", ages)); ages = persons.FindBySecondKey("Kenov"); Console.WriteLine(string.Join(", ", ages)); ages = persons.FindByBothKeys("Nikolay", "Petrov"); Console.WriteLine(string.Join(", ", ages)); }
static void Main(string[] args) { BiDictionary <int, string, string> biDictionary = new BiDictionary <int, string, string>(); for (int i = 0; i < 10; i++) { biDictionary.Add(i, i.ToString(), string.Format("entry{0}", i)); } ICollection <string> found; biDictionary.Add(0, "0", "duplicatedEntry0"); found = biDictionary.FindUsingFirstKey(0); PrintCollection <string>(found); biDictionary.Add(1, "2", "duplicateInThreeDictionaries"); found = biDictionary.FindUsingBothKeys(1, "2"); PrintCollection(found); found = biDictionary.FindUsingBothKeys(5, "5"); PrintCollection(found); biDictionary.Add(100, "99", "only value for those keys"); PrintCollection(biDictionary.FindUsingFirstKey(100)); PrintCollection(biDictionary.FindUsingSecondKey("99")); biDictionary.RemoveWithFirstKey(1); found = biDictionary.FindUsingFirstKey(1); Console.WriteLine("Found items after removing with first key: {0}", found.Count > 0); biDictionary.RemoveWithSecondKey("0"); found = biDictionary.FindUsingSecondKey("0"); Console.WriteLine("Found items after removing with second key: {0}", found.Count > 0); found = biDictionary.FindUsingFirstKey(0); Console.WriteLine("Found items with first key: {0}", found.Count > 0); biDictionary.RemoveWithBothKeys(100, "99"); found = biDictionary.FindUsingBothKeys(100, "99"); Console.WriteLine("Found items after removing with both keys: {0}", found.Count > 0); }
public static void Main() { BiDictionary <string, int, int> biDictionary = new BiDictionary <string, int, int>(); biDictionary.Add("One", 2, 3); var stringKeysValues = biDictionary.FindFirstKey("One"); foreach (var pair in stringKeysValues) { Console.WriteLine(pair); } var intKeysValues = biDictionary.FindSecondKey(2); foreach (var pair in intKeysValues) { Console.WriteLine(pair); } }
public static void Main() { var tuple = new BiDictionary <string, string, string>(); tuple.Add("Pesho", "Peshov", "*****@*****.**"); tuple.Add("Gosho", "Goshov", "*****@*****.**"); tuple.Add("Tosho", "Toshov", "*****@*****.**"); var pesho = tuple.FindByKey1("Pesho"); Console.WriteLine(pesho); var gosho = tuple.FindByKey2("Goshov"); Console.WriteLine(gosho); var tosho = tuple.FindByTwoKeys("Tosho", "Toshov"); Console.WriteLine(tosho); }