Class SearchProgram

java.lang.Object
application.model.search.SearchProgram
Direct Known Subclasses:
AgarSearch, BruteForceSearch, CatalystSearch, RuleSearch, ShipSearch

public abstract class SearchProgram
extends java.lang.Object
All search programs built into CAViewer should inherit from this
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.util.concurrent.ExecutorService executor  
    protected int numSearched  
    protected SearchParameters searchParameters  
    protected java.util.ArrayList<Pattern> searchResults  
    protected boolean stop  
  • Constructor Summary

    Constructors 
    Constructor Description
    SearchProgram​(SearchParameters parameters)
    Constructs a search program with the provided parameters
  • Method Summary

    Modifier and Type Method Description
    <T> void add​(java.util.List<T> list, T object)
    Adds an object to a list (thread-safe)
    <T> void add​(java.util.Set<T> set, T object)
    Adds an object to a set (thread-safe)
    int getNumSearched()
    Gets the number of objects searched
    SearchParameters getSearchParameters()
    Gets the search parameters
    java.util.ArrayList<Pattern> getSearchResults()
    Gets the search results
    abstract void search​(int num)
    Search for something num times
    void searchThreaded​(int num, int numThreads)
    Performs the search but with multi-threading
    void terminateSearch()
    Terminates the search process
    abstract boolean writeToFile​(java.io.File file)
    Writes the search results to a file

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • SearchProgram

      public SearchProgram​(SearchParameters parameters)
      Constructs a search program with the provided parameters
      Parameters:
      parameters - The parameters of the search program
  • Method Details

    • add

      public <T> void add​(java.util.List<T> list, T object)
      Adds an object to a list (thread-safe)
      Type Parameters:
      T - The type of the object
      Parameters:
      list - The list to add the object to
      object - The object to be added
    • add

      public <T> void add​(java.util.Set<T> set, T object)
      Adds an object to a set (thread-safe)
      Type Parameters:
      T - The type of the object
      Parameters:
      set - The set to add the object to
      object - The object to be added
    • search

      public abstract void search​(int num)
      Search for something num times
      Parameters:
      num - The number of times to search for something
    • searchThreaded

      public void searchThreaded​(int num, int numThreads)
      Performs the search but with multi-threading
      Parameters:
      num - The number of times to search for something
      numThreads - The number of threads to use in the search
    • terminateSearch

      public void terminateSearch()
      Terminates the search process
    • getSearchResults

      public java.util.ArrayList<Pattern> getSearchResults()
      Gets the search results
      Returns:
      Returns the search results
    • getSearchParameters

      public SearchParameters getSearchParameters()
      Gets the search parameters
      Returns:
      Returns the search parameters
    • getNumSearched

      public int getNumSearched()
      Gets the number of objects searched
      Returns:
      Returns the number of objects searched
    • writeToFile

      public abstract boolean writeToFile​(java.io.File file)
      Writes the search results to a file
      Parameters:
      file - The file to write the search results to
      Returns:
      Returns true if successful, false if unsuccessful