title: Synchronous pattern matching algorithm for multiple concatenated strings
body: <p>For a class subject, I must implement a class that looks for a pattern in a set of chars that the class receives in a chronological order. Each character the class receives has a particular source (a planete, identified by an int ID).</p>
  
  <p>We have to implement the data structure ourselves, and so I implemented a String List where I store all these characters in a chronological order.</p>
  
  <p>The problem is that the pattern must be matched for characters coming from the same planete (source), so pattern matching must be made on each source.</p>
  
  <p>I tried to use famous pattern matching algorithms like Rabin Karp by browsing the whole list and only taking into account the currently browsed source, and then doing this for all the sources, but the performances are really lame, even worse than a naive (but synchronous) solution.</p>
  
  <p>Do you have any idea about which algorithm could be more efficient in that case ? (letting me use each character I'm browsing, even if this implies storing the actual "search state" of that source somewhere, like we did for the naive implementation)</p>
  
  <p>P.S: The IDs are finite (from 1 to 128) but the number of chars can go up to 10⁷</p>
  
  <p><strong>EDIT:</strong> Here are some details that will hopefully clarify things.</p>
  
  <p><code>IntlFinder</code>, my class,can receive characters (or array of characters) by a method <code>Add(char* pszData, int nSource)</code>; Hence, each character is coupled with a Source ID. The pair (character, source) is stored in a StringList <code>ComList</code> (in chronological order of their addition).</p>
  
  <p>For the pattern to be present in my class, it must be present for THE SAME SOURCE.</p>
  
  <p>Example:</p>
  
  <p>If I'm looking for the pattern SAYKOUK</p>
  
  <p>(<strong>S</strong>, 1); (<strong>A</strong>, 1); (<strong>Y</strong>, 1); (<strong>K</strong>, 1); (Z, 2); (S, 3); (<strong>O</strong>, 1); (<strong>U</strong>, 1); (<strong>K</strong>, 1) 
  is OK !</p>
  
  <p>(<strong>S</strong>, 1); (<strong>A</strong>, 1); (<strong>Y</strong>, 1); (K, 2); (O, 3); (U, 1); (K, 4) 
  is not OK.</p>
  
  <p>This is problametic because if I only consider one source (ranging from 1 to 128) and browse the whole list each time, my pattern searching method is <em>REALLY</em> slow. And I can't manage with any of these algorithms to take into account the characters of the different sources and know whenever I met my pattern with any of them !</p>