Package application.model.search
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.ExecutorServiceexecutorprotected intnumSearchedprotected SearchParameterssearchParametersprotected java.util.ArrayList<Pattern>searchResultsprotected booleanstop -
Constructor Summary
Constructors Constructor Description SearchProgram(SearchParameters parameters)Constructs a search program with the provided parameters -
Method Summary
Modifier and Type Method Description <T> voidadd(java.util.List<T> list, T object)Adds an object to a list (thread-safe)<T> voidadd(java.util.Set<T> set, T object)Adds an object to a set (thread-safe)intgetNumSearched()Gets the number of objects searchedSearchParametersgetSearchParameters()Gets the search parametersjava.util.ArrayList<Pattern>getSearchResults()Gets the search resultsabstract voidsearch(int num)Search for something num timesvoidsearchThreaded(int num, int numThreads)Performs the search but with multi-threadingvoidterminateSearch()Terminates the search processabstract booleanwriteToFile(java.io.File file)Writes the search results to a file
-
Field Details
-
numSearched
protected int numSearched -
executor
protected java.util.concurrent.ExecutorService executor -
searchParameters
-
searchResults
-
stop
protected boolean stop
-
-
Constructor Details
-
SearchProgram
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 toobject- 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 toobject- 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 somethingnumThreads- The number of threads to use in the search
-
terminateSearch
public void terminateSearch()Terminates the search process -
getSearchResults
Gets the search results- Returns:
- Returns the search results
-
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
-