title: A faster Search Algorithm in a JTable
body: <p>I'm trying to implement my own JTable RowFilter, since I'm using Java 1.4 (RowFilter doesn't seem to exist in this version). I still believe however that the algorithm that I'm using can be replaced by a much faster one. I have tried my algorithm on a dummy table that contains 30.000 records and 8 columns, and I'm getting the result in less than a second. But sometimes, there's this little delay that occurs while typing in the Search Criteria (Which is basically a JTextField with a DocumentListener). Here's the algorithm I'm using:</p>
  
  <pre><code>    public void searchList()
      {  
  
          for(int i=0;i&lt;list.size();i++)
          {
              Employee e=(Employee)list.get(i);
  
              Pattern pattern=Pattern.compile(search.getText(),Pattern.CASE_INSENSITIVE);
              Matcher matcher=pattern.matcher(e.getFname());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getLname());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getHeight());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getOccupation());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getSize());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getSkills());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getSsn());
              if(matcher.find())
              {
                  result.add(e);
                  continue;   
              }
              matcher=pattern.matcher(e.getStrength());
              if(matcher.find())
              {
                  result.add(e);
  
              }
          }
          model.fireTableDataChanged();
          table.updateUI();
      }
      }
  </code></pre>
  
  <p>The main datastructure that I'm using to bind data to my TableModel is an ArrayList that holds objects of a class called "Employee". Another ArrayList called result, contains all the "Employee" objects that matched the search criteria. Bear in mind that the filtering is happening on all 8 columns. The only optimization that I think I did is adding the "Employee" object on the first column match, instead of having to go through the rest of the columns. </p>
  
  <p>Any suggestions regarding this matter? Thanks a lot for the help =)</p>