Esempio n. 1
0
        public baseHashSet(int initSize)
        {
            int size = MathTool.nextPrime((int)Math.Ceiling(initSize / _maxLoadFactor));

            _ary = new K[size];
            //bool[] will have the default value of false
            _aryValid = new bool[size];
        }
Esempio n. 2
0
        public static void summarize(string fn = "f2")
        {
            StreamReader sr  = new StreamReader(Global.outDir + Global.fResRaw);
            string       txt = sr.ReadToEnd();

            sr.Close();
            txt = txt.Replace("\r", "");
            string[]     regions = txt.Split(Global.triLineEndAry, StringSplitOptions.RemoveEmptyEntries);
            StreamWriter sw      = new StreamWriter(Global.outDir + Global.fResSum);

            foreach (string region in regions)
            {
                string[]       blocks = region.Split(Global.biLineEndAry, StringSplitOptions.RemoveEmptyEntries);
                List <dMatrix> mList  = new List <dMatrix>();
                foreach (string im in blocks)
                {
                    dMatrix m = new dMatrix(im);
                    mList.Add(m);
                }

                //get average
                dMatrix avgM = new dMatrix(mList[0]);
                avgM.set(0);
                foreach (dMatrix m in mList)
                {
                    avgM.add(m);
                }
                avgM.divide(mList.Count);
                //get devi
                dMatrix deviM = MathTool.getDeviation(mList);

                sw.WriteLine("%averaged values:");
                avgM.write(sw, fn);
                sw.WriteLine();
                sw.WriteLine("%deviations:");
                deviM.write(sw, fn);
                sw.WriteLine();
                sw.WriteLine("%avg & devi:");

                sMatrix sAvgM = new sMatrix(avgM, fn);
                sAvgM.add("+-");
                sMatrix sDeviM = new sMatrix(deviM, fn);
                sAvgM.add(sDeviM);
                sAvgM.write(sw);
                sw.WriteLine("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n");
            }
            sw.Close();
        }
Esempio n. 3
0
 private void rehash()
 {
     K[]    oldAry      = _ary;
     bool[] oldAryValid = _aryValid;
     _ary      = new K[MathTool.nextPrime(oldAry.Length * 2)];
     _aryValid = new bool[_ary.Length];
     for (int i = 0; i < oldAry.Length; i++)
     {
         if (oldAryValid[i])
         {
             int loc = loc_findSlot(oldAry[i]);
             _ary[loc]      = oldAry[i];
             _aryValid[loc] = true;
         }
     }
 }
Esempio n. 4
0
        private void rehash()
        {
            pair[] oldAry      = _ary;
            bool[] oldAryValid = _aryValid;
            int    newSize     = MathTool.nextPrime(oldAry.Length * 2);

            _ary      = new pair[newSize];
            _aryValid = new bool[_ary.Length];
            for (int i = 0; i < oldAry.Length; i++)
            {
                if (oldAryValid[i])
                {
                    int loc = loc_findSlot(oldAry[i].key);
                    _ary[loc].key   = oldAry[i].key;
                    _ary[loc].value = oldAry[i].value;
                    _aryValid[loc]  = true;
                }
            }
        }