Exemple #1
0
        static void Main(string[] args)
        {
            LinearProbingHashST <string, int> lp = new LinearProbingHashST <string, int>(16);

            string[] a =
            {
                "S",
                "E",
                "A",
                "R",
                "C",
                "H",
                "E",
                "X",
                "A",
                "M",
                "P",
                "L",
                "E"
            };

            for (int i = 0; i < a.Length; i++)
            {
                lp.put(a[i], i);
            }
            lp.ConsoleDisplay();
            Console.ReadLine();
        }
Exemple #2
0
        // resizes the hash table to the given capacity by re-hashing all of the keys
        private void resize(int capacity)
        {
            LinearProbingHashST <Key, Value> temp = new LinearProbingHashST <Key, Value>(capacity);

            for (int i = 0; i < m; i++)
            {
                if (keys[i] != null)
                {
                    temp.put(keys[i], vals[i]);
                }
            }
            keys = temp.keys;
            vals = temp.vals;
            m    = temp.m;
        }