コード例 #1
0
ファイル: Program.cs プロジェクト: allanma88/SampleCode
        public STBase <int, string> GetST(int n, string stType)
        {
            STBase <int, string> st = null;

            switch (stType)
            {
            case "binarysearch":
                st = new BinarySearchST <int, string>(n);
                break;

            case "bst":
            case "bstloop":
                st = new BinarySearchTree_Loop <int, string>();
                break;

            case "bstrecur":
                st = new BinarySearchTree_Recur <int, string>();
                break;

            case "hash":
            case "schash":
                st = new SeparateChainingHashST <int, string>();
                break;

            case "lphash":
                st = new LinearProbingHashST <int, string>();
                break;

            default:
                break;
            }
            return(st);
        }
コード例 #2
0
        private void Resize(int cap)
        {
            var st = new LinearProbingHashST <TKey, TValue>(cap);

            foreach (TKey key in Keys())
            {
                st.Put(key, Get(key));
            }
            _keys   = st._keys;
            _values = st._values;
            _M      = st._M;
        }