Esempio n. 1
0
        /// <summary>Gets inizializeted similar words for given seed word.</summary>
        /// <param name="seedNumber">Serial number of seed word.</param>
        /// <returns>The total nubmer of filled similars.</returns>
        /// <remarks>In Turbo mode getting Similars are saved and returned from memory by requery.</remarks>
        public static Similars GetSimilars(int seedNumber)
        {
            if (_MismatchCount == 0)
            {
                return(null);
            }
            _Word = Words.GetWord(seedNumber);
            int sum = 0;

            if (_IsTurbo)
            {
                Similars smls = _ArrSimilars[seedNumber];
                if (smls == null)
                {
                    // create and fill Similars
                    _ArrSimilars[seedNumber] = smls = new Similars(_Capacity);
                    Fill_recurs(0, _MismatchCount, seedNumber, smls._numbers, ref sum, true);
                }
                return(smls);
            }
            else
            {
                Fill_recurs(0, _MismatchCount, seedNumber, _Similars._numbers, ref sum, true);
                return(_Similars);
            }
        }
Esempio n. 2
0
 static void ShowTemplate(byte[] names)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     for (int i = 0; i < names.Length / Words.WordLength; i++)
     {
         sb.Append(string.Format("{0}: {1}  ", i * Words.WordLength, Words.GetWord(i * Words.WordLength)));
     }
     System.Windows.Forms.MessageBox.Show(
         String.Format("{0}", sb.ToString()), "",
         System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
 }
Esempio n. 3
0
        /// <summary>
        /// Gets sum total of the values of referenced array, indexed by the numbers of similar words for given seed word.
        /// </summary>
        /// <param name="seedNumber">Serial number of seed word.</param>
        /// <param name="summands">Array of integers should be sum, indexed by similar number.</param>
        /// <returns>The total sum.</returns>
        public static int SumUp(int seedNumber, int[] summands)
        {
            int sum = 0;

            if (_MismatchCount > 0)
            {
                _Word = Words.GetWord(seedNumber);
                Fill_recurs(0, _MismatchCount, seedNumber, summands, ref sum, false);
            }
            return(sum);
        }
Esempio n. 4
0
 /// <summary>Gets the string represented the word by its serial number.</summary>
 /// <param name="wordNumber">The number of word in the total words sequence.</param>
 /// <param name="isEOL">True if 'end-of-line' character is added to the end of string.</param>
 /// <returns>The string represented the word.</returns>
 public static string WordToString(int number, bool isEOL)
 {
     byte[] word = Words.GetWord(number);
     char[] res  = new char[Words.WordLength + (isEOL ? 1 : 0)];
     for (byte i = 0; i < Words.WordLength; i++)
     {
         res[i] = Chars.GetChar(word[i]);
     }
     if (isEOL)
     {
         res[Words.WordLength] = Abbr.EOL;
     }
     return(new string(res));
 }