예제 #1
0
        static void Main(string[] args)
        {
            SuperHashTable <Person> superHashTable = new SuperHashTable <Person>();

            Person p1 = new Person("Nikita", 17, 0);
            Person p2 = new Person("Alex", 20, 0);

            superHashTable.Add(new Person("Vika", 16, 1));
            superHashTable.Add(p1);
            superHashTable.Add(p2);

            Console.WriteLine(superHashTable.Search(p1));
            Console.WriteLine(superHashTable.Search(p2));
            Console.WriteLine(superHashTable.Search(new Person("Vika", 16, 1)));
            Console.WriteLine((superHashTable.Search(new Person("Unknown", 99, 2))));

            Console.ReadLine();

            HashTable <int, string> hashTable = new HashTable <int, string>();

            hashTable.Add(1, "Андрей");
            hashTable.Add(12, "Никита");
            hashTable.Add(1, "Алексей");

            Console.WriteLine(hashTable.Search(1, "Алексей"));
            Console.WriteLine(hashTable.Search(1, "Андрей"));
            Console.WriteLine(hashTable.Search(12, "Никита"));
            Console.WriteLine(hashTable.Search(15, "Unknown"));

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var superHashTable = new SuperHashTable <Person>(100);
            var person         = new Person()
            {
                Name = "Denis", Age = 21, Gender = 0
            };

            superHashTable.Add(new Person()
            {
                Name = "Dima", Age = 35, Gender = 0
            });
            superHashTable.Add(new Person()
            {
                Name = "Andrew", Age = 18, Gender = 0
            });
            superHashTable.Add(new Person()
            {
                Name = "Kitty", Age = 24, Gender = 1
            });
            superHashTable.Add(person);

            Console.WriteLine(superHashTable.Search(new Person()
            {
                Name = "Denis", Age = 21, Gender = 0
            }));
            Console.WriteLine(superHashTable.Search(person));

            Console.ReadLine();


            var hashTable = new HashTable <int, string>(100);

            hashTable.Add(5, "Hello");
            hashTable.Add(18, "World");
            hashTable.Add(777, "Hi");
            //Colission
            hashTable.Add(7, "Wassup");

            Console.WriteLine(hashTable.Search(6, "KEK"));
            Console.WriteLine(hashTable.Search(18, "World"));

            Console.ReadLine();



            var badHashTable = new BadHashTable <int>(100);

            badHashTable.Add(5);
            badHashTable.Add(18);
            badHashTable.Add(777);
            //Colission
            badHashTable.Add(7);

            Console.WriteLine(badHashTable.Search(6));
            Console.WriteLine(badHashTable.Search(18));

            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var superHashTable = new SuperHashTable <Person>(100);
            var person         = new Person()
            {
                Name = "Juliy", Age = 12, Gender = 1
            };

            superHashTable.Add(new Person()
            {
                Name = "Olaf", Age = 25, Gender = 0
            });
            superHashTable.Add(new Person()
            {
                Name = "Tom", Age = 22, Gender = 0
            });
            superHashTable.Add(new Person()
            {
                Name = "Nino", Age = 26, Gender = 1
            });
            superHashTable.Add(new Person()
            {
                Name = "Maus", Age = 35, Gender = 0
            });
            superHashTable.Add(person);

            Console.WriteLine(superHashTable.Search(new Person()
            {
                Name = "Tom", Age = 22, Gender = 0
            }));
            Console.WriteLine(superHashTable.Search(person));


            Console.ReadLine();

            var hashTable = new HashTable <int, string>(100);

            hashTable.Add(5, "Hallo");
            hashTable.Add(18, "Bye");

            Console.WriteLine(hashTable.Search(18, "Bye"));
            Console.WriteLine(hashTable.Search(12, "Hallo"));

            Console.WriteLine();

            var badHashTable = new BadHashTable <int>(100);

            badHashTable.Add(5);
            badHashTable.Add(18);
            badHashTable.Add(5777);

            Console.WriteLine(badHashTable.Search(6));
            Console.WriteLine(badHashTable.Search(18));


            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            var hastable = new SuperHashTable <Person>(100);
            var persone  = new Person()
            {
                Name = "Vasya", Age = 23, Gender = "Man"
            };

            hastable.Add(new Person()
            {
                Name = "Aravan", Age = 13, Gender = "Man"
            });
            hastable.Add(new Person()
            {
                Name = "Annush", Age = 25, Gender = "Woman"
            });
            hastable.Add(persone);
            Console.WriteLine(hastable.Search(new Person()
            {
                Name = "Annush", Age = 25, Gender = "Woman"
            }));
            Console.WriteLine(hastable.Search(persone));
            Console.ReadLine();
        }
예제 #5
0
        private static void Main()
        {
            BadHashTable <int> badHashTable = new BadHashTable <int>(10);

            badHashTable.Add(5);
            badHashTable.Add(18);
            badHashTable.Add(777);

            Console.WriteLine(badHashTable.Search(6));
            Console.WriteLine(badHashTable.Search(18));
            Console.ReadLine();
            Console.Clear();

            HashTable <int, string> hashTable = new HashTable <int, string>(10);

            hashTable.Add(5, "Hello");
            hashTable.Add(18, "World");
            hashTable.Add(777, "!");

            Console.WriteLine(hashTable.Search(6, "Lol"));
            Console.WriteLine(hashTable.Search(18, "World"));
            Console.ReadLine();
            Console.Clear();

            SuperHashTable <Person> superHashTable = new SuperHashTable <Person>(10);
            Person person = new Person()
            {
                Name = "A", Age = 25, Gender = 0
            };

            superHashTable.Add(new Person()
            {
                Name = "A", Age = 25, Gender = 0
            });
            superHashTable.Add(person);
            superHashTable.Add(new Person()
            {
                Name = "C", Age = 21, Gender = 1
            });

            Console.WriteLine(superHashTable.Search(new Person()
            {
                Name = "A", Age = 25, Gender = 0
            }));
            Console.WriteLine(superHashTable.Search(person));
            Console.ReadLine();
            Console.Clear();

            OpenHashingHashTable <string, string> openHashingHashTable = new OpenHashingHashTable <string, string>();

            openHashingHashTable.Insert("Little Prince", "I never wished you any sort of harm; but you wanted me to tame you...");
            openHashingHashTable.Insert("Fox", "And now here is my secret, a very simple secret: It is only with the heart that one can see rightly; what is essential is invisible to the eye.");
            openHashingHashTable.Insert("Rose", "Well, I must endure the presence of two or three caterpillars if I wish to become acquainted with the butterflies.");
            openHashingHashTable.Insert("King", "He did not know how the world is simplified for kings. To them, all men are subjects.");

            ShowHashTable(openHashingHashTable, "Created hashtable.");

            openHashingHashTable.Delete("King");
            ShowHashTable(openHashingHashTable, "Delete item from hashtable.");

            Console.WriteLine($"Little Prince say: {openHashingHashTable.Search("Little Prince")}");
        }
예제 #6
0
        static void Main(string[] args)
        {
            var superHashTable = new SuperHashTable <Person>(100);
            var person         = new Person()
            {
                Name = "Andriy", Age = 20, Gender = 0
            };

            superHashTable.Add(new Person()
            {
                Name = "Yaroslav", Age = 20, Gender = 0
            });
            superHashTable.Add(new Person()
            {
                Name = "Kate", Age = 17, Gender = 1
            });
            superHashTable.Add(new Person()
            {
                Name = "Vasya", Age = 25, Gender = 0
            });
            superHashTable.Add(new Person()
            {
                Name = "Yuriy", Age = 28, Gender = 0
            });
            superHashTable.Add(person);

            Console.WriteLine(superHashTable.Search(new Person()
            {
                Name = "Andriy", Age = 20, Gender = 0
            }));
            Console.WriteLine(superHashTable.Search(person));

            Console.WriteLine();

            var person1 = new Person()
            {
                Name = "Andriy", Age = 20, Gender = 0, Id = 1
            };
            var person2 = new Person()
            {
                Name = "Kate", Age = 17, Gender = 1, Id = 2
            };
            var person3 = new Person()
            {
                Name = "Vasya", Age = 25, Gender = 0, Id = 3
            };
            var hashTable = new HashTable <int, Person>(10);

            hashTable.Add(person1.Id, person);
            hashTable.Add(person2.Id, person);
            hashTable.Add(person3.Id, person);
            Console.WriteLine(hashTable.Search(person1.Id, person1));
            Console.WriteLine(hashTable.Search(person2.Id, person3));


            //var hashTable = new HashTable<int, string>(100);
            //hashTable.Add(5, "Hello");
            //hashTable.Add(18, "World");
            //hashTable.Add(777, "Hey");
            //hashTable.Add(7, "Developer");


            //Console.WriteLine(hashTable.Search(6, "Andriy"));
            //Console.WriteLine(hashTable.Search(18, "World"));

            Console.WriteLine();

            var badHashTable = new BadHashTable <int>(100);

            badHashTable.Add(5);
            badHashTable.Add(18);
            badHashTable.Add(777);
            badHashTable.Add(7);

            Console.WriteLine(badHashTable.Search(6));
            Console.WriteLine(badHashTable.Search(18));

            Console.ReadLine();
        }