Beispiel #1
0
 static void TestExpand(A_HashTable <int, string> ht)
 {
     ht.Add(23, "Ron");
     ht.Add(26, "Jim");
     ht.Add(43, "Bob");
     ht.Add(33, "Jane");
     ht.Add(17, "Bryce");
 }
Beispiel #2
0
        static void LoadDataFromFile(A_HashTable <Person, Person> ht)
        {
            StreamReader sr     = new StreamReader(File.Open("People.txt", FileMode.Open));
            string       sInput = "";

            try
            {
                //Read a line from the file
                while ((sInput = sr.ReadLine()) != null)
                {
                    try
                    {
                        char[]   cArray = { ' ' };
                        string[] sArray = sInput.Split(cArray);
                        int      iSSN   = Int32.Parse(sArray[0]);
                        Person   p      = new Person(iSSN, sArray[2], sArray[1]);
                        ht.Add(p, p);
                    }
                    catch (ApplicationException ae)
                    {
                        //Console.WriteLine("Exception: " + ae.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            sr.Close();
        }
Beispiel #3
0
        static void TestAdd(A_HashTable <int, string> ht)
        {
            ht.Add(11, "Rob");
            ht.Add(15, "Grace");

            // shouldn't add "John" he has a dplicate key
            ht.Add(15, "John");
            ht.Add(20, "Luke");
            ht.Add(25, "Cuong");
            ht.Add(26, "Jaryd");
            ht.Add(9, "Austin");
            //ht.Add(17, "Bryce");
        }