Generic Class Library - bugs, description, questions, usage and suggestions - page 7

 
I should add that I used two functions and one array in the solution. No pointers or connections.
 
Tag Konow:
There is a solution. However, to temporarily keep the intrigue, I'd like to put here the excerpt. Next, skilled people will compare the performance of my solution and the solution provided by the author above. I wonder which works faster.

I checked, Vasiliy's version works faster. It is ~3.2 times faster on my car. If you can speed it up, come on over.

 
fxsaber:

I checked, Vasiliy's version works faster. It is ~3.2 times faster on my car. If you can speed it up, come to me.

I see, thank you. Perhaps someone else will check for objectivity.
 
fxsaber:

I checked, Vasiliy's version works faster. It is ~3.2 times faster on my car. If you can speed it up, come on over.

Can you tell me more about how you tested it?
 
Konow's tag:
Can you elaborate on how you tested it?
Perhaps the input field is slowing down. I'll make a version without it. Like Vasily's in the script.
 
Tag Konow:
Can you tell me more about how you tested it?

Not yet. I want, as you do, to keep the intrigue alive.

 
Konow tag:
Perhaps the input field is slow. I'll make a version without it. Like Vasiliy's in the script.

Write open source code here. All the following exeshniks will be deleted here. This is not a contest.

 
Artyom Trishkin:

Write open source code here. All further exeshniks here will be deleted. This is not a contest.

Yes, I just wanted to post it.

 

This is what it looks like:

//+------------------------------------------------------------------+
//|                                                Dictiuonary 2.mq5 |
//|                                                      Peter Konow |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Peter Konow"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#define  Max_possible_collisions    100
#define  Max_letters_in_word        100
#define  All_letters_in_alphabet    255
//------------------------------------
string Dictionary[Max_possible_collisions][All_letters_in_alphabet][Max_letters_in_word];
//-------------------------------------------------------------------

//+------------------------------------------------------------------+

void Add(string word)
{
 uchar First_letter = (uchar)StringGetCharacter(word,0) - 97;
 //-----------------------
 int All_letters_in_word = StringLen(word);
 //-----------------------
 for(int a1 = 0; a1 < Max_possible_collisions; a1++)
   {
     string word_inside = Dictionary[a1][First_letter][All_letters_in_word];
     //-----------------------   
    if(word_inside == NULL)
      {
       Dictionary[a1][First_letter][All_letters_in_word] = word;
       Print("Your word has been added to our dictionary!");
       break;
      }
    if(word_inside == word)
      {
       Print("This word already exists in our dictionary");
       break;
      } 
   }   
 //------------------------   
}
//--------------------------------------------------------------------+

//--------------------------------------------------------------------+

void OnStart()
  {
   //---
   Add("Text 1");
   
   Add("Text 1");
  }
//+------------------------------------------------------------------+
 
I had to increase the size of the array, because capital letters have a different code and "fall out" of the array.