Exemplo n.º 1
0
 private static void ProcessCharRepetition(char previous_char, int repetition_length, long position, SortedDictionary<char, SortedDictionary<int, CharRepetition>> char_repetitions_table)
 {
     try
     {
         // if char exist
         if (char_repetitions_table.ContainsKey(previous_char))
         {
             // if repetition_length exist, increment frequency
             if ((char_repetitions_table[previous_char]).ContainsKey(repetition_length))
             {
                 ((char_repetitions_table[previous_char])[repetition_length]).frequency++;
                 //if (((char_repetitions_table[previous_char])[repetition_length]).position == -1L)
                 //{
                 //    ((char_repetitions_table[previous_char])[repetition_length]).position = (position - (repetition_length - 1));
                 //}
                 if (((char_repetitions_table[previous_char])[repetition_length]).positions.Count <= s_max_positions)
                 {
                     ((char_repetitions_table[previous_char])[repetition_length]).positions.Add(position - (repetition_length - 1));
                 }
                 else
                 {
                     ((char_repetitions_table[previous_char])[repetition_length]).positions[s_max_positions] = (position - (repetition_length - 1));
                 }
             }
             else // char exist but new repetition_length
             {
                 CharRepetition char_repetition = new CharRepetition();
                 char_repetition.length = repetition_length;
                 char_repetition.frequency = 1;
                 //if (char_repetition.position == -1L)
                 //{
                 //    char_repetition.position = (position - (repetition_length - 1));
                 //}
                 if (char_repetition.positions.Count <= s_max_positions)
                 {
                     char_repetition.positions.Add(position - (repetition_length - 1));
                 }
                 else
                 {
                     char_repetition.positions[s_max_positions] = (position - (repetition_length - 1));
                 }
                 char_repetitions_table[previous_char].Add(repetition_length, char_repetition);
             }
         }
         else // new char, new repetition_length
         {
             CharRepetition char_repetition = new CharRepetition();
             char_repetition.length = repetition_length;
             char_repetition.frequency = 1;
             //if (char_repetition.position == -1L)
             //{
             //    char_repetition.position = (position - (repetition_length - 1));
             //}
             if (char_repetition.positions.Count <= s_max_positions)
             {
                 char_repetition.positions.Add(position - (repetition_length - 1));
             }
             else
             {
                 char_repetition.positions[s_max_positions] = (position - (repetition_length - 1));
             }
             SortedDictionary<int, CharRepetition> char_repetitions = new SortedDictionary<int, CharRepetition>();
             char_repetitions.Add(repetition_length, char_repetition);
             char_repetitions_table.Add(previous_char, char_repetitions);
         }
     }
     catch (Exception ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(ex);
         Console.ForegroundColor = ConsoleColor.White;
     }
 }
Exemplo n.º 2
0
 private static void ProcessCharRepetition(char previous_char, int repetition_length, long position, SortedDictionary<char, SortedDictionary<int, CharRepetition>> char_repetitions_table)
 {
     try
     {
         // if char exist
         if (char_repetitions_table.ContainsKey(previous_char))
         {
             // if repetition_length exist, increment frequency
             if ((char_repetitions_table[previous_char]).ContainsKey(repetition_length))
             {
                 ((char_repetitions_table[previous_char])[repetition_length]).frequency++;
                 //if (((char_repetitions_table[previous_char])[repetition_length]).position == -1L)
                 //{
                 //    ((char_repetitions_table[previous_char])[repetition_length]).position = (position - (repetition_length - 1));
                 //}
                 if (((char_repetitions_table[previous_char])[repetition_length]).positions.Count <= s_max_positions)
                 {
                     ((char_repetitions_table[previous_char])[repetition_length]).positions.Add(position - (repetition_length - 1));
                 }
                 else
                 {
                     ((char_repetitions_table[previous_char])[repetition_length]).positions[s_max_positions] = (position - (repetition_length - 1));
                 }
             }
             else // char exist but new repetition_length
             {
                 CharRepetition char_repetition = new CharRepetition();
                 char_repetition.length = repetition_length;
                 char_repetition.frequency = 1;
                 //if (char_repetition.position == -1L)
                 //{
                 //    char_repetition.position = (position - (repetition_length - 1));
                 //}
                 if (char_repetition.positions.Count <= s_max_positions)
                 {
                     char_repetition.positions.Add(position - (repetition_length - 1));
                 }
                 else
                 {
                     char_repetition.positions[s_max_positions] = (position - (repetition_length - 1));
                 }
                 char_repetitions_table[previous_char].Add(repetition_length, char_repetition);
             }
         }
         else // new char, new repetition_length
         {
             CharRepetition char_repetition = new CharRepetition();
             char_repetition.length = repetition_length;
             char_repetition.frequency = 1;
             //if (char_repetition.position == -1L)
             //{
             //    char_repetition.position = (position - (repetition_length - 1));
             //}
             if (char_repetition.positions.Count <= s_max_positions)
             {
                 char_repetition.positions.Add(position - (repetition_length - 1));
             }
             else
             {
                 char_repetition.positions[s_max_positions] = (position - (repetition_length - 1));
             }
             SortedDictionary<int, CharRepetition> char_repetitions = new SortedDictionary<int, CharRepetition>();
             char_repetitions.Add(repetition_length, char_repetition);
             char_repetitions_table.Add(previous_char, char_repetitions);
         }
     }
     catch (Exception ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(ex);
         Console.ForegroundColor = ConsoleColor.White;
     }
 }