Class Solver
Class that searches for the solution to a puzzle according to its description and some provided parameters. This class implements ISolver and cannot be inherited.
Inheritance
Implements
Namespace: TreeProblemFramework.Solver
Constructors
Solver(IDescriptor, IParameters)
Initializes a new instance of the Solver class.
Declaration
public Solver(IDescriptor descriptor, IParameters parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| IDescriptor | descriptor | The object that contains the description of the puzzle whose solution is to be found. |
| IParameters | parameters | The object that defines which parameters are to be used in order to perform the search for a solution to the puzzle. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown when one or more required arguments are null. |
Properties
Descriptor
Gets the object that contains the description of the puzzle whose solution is to be found.
Declaration
public IDescriptor Descriptor { get; }
Property Value
| Type | Description |
|---|---|
| IDescriptor | An object that implements the IDescriptor interface. |
Parameters
Gets the object that defines which parameters are to be used in order to perform the search for a solution to the puzzle.
Declaration
public IParameters Parameters { get; }
Property Value
| Type | Description |
|---|---|
| IParameters | An object that implements the IParameters interface. |
Methods
FindAllSolutions(IEnvironment)
Method that searches for all possible solutions to the puzzle according to its description and the provided parameters.
Declaration
public IEnumerable<Solution> FindAllSolutions(IEnvironment initialEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironment | initialEnvironment | The environment from which to begin the search. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<Solution> | An enumerator that yields each solution as it is found. |
FindAllSolutionsAsync(IEnvironment)
Asynchronous method that searches for all possible solutions to the puzzle according to its description and the provided parameters. It wraps the FindAllSolutions(IEnvironment) method.
Declaration
public IAsyncEnumerable<Solution> FindAllSolutionsAsync(IEnvironment initialEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironment | initialEnvironment | The environment from which to begin the search. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IAsyncEnumerable<Solution> | An asynchronous enumerator that yields each solution as it is found. |
FindOneSolution(IEnvironment)
Method that searches for one (first) solution to the puzzle according to its description and the provided parameters.
Declaration
public Solution FindOneSolution(IEnvironment initialEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironment | initialEnvironment | The environment from which to begin the search. |
Returns
| Type | Description |
|---|---|
| Solution | The one solution, if found, or |
FindOneSolutionAsync(IEnvironment)
Asynchronous method that searches for one (first) solution to the puzzle according to its description and the provided parameters. It wraps the FindOneSolution(IEnvironment) method.
Declaration
public Task<Solution> FindOneSolutionAsync(IEnvironment initialEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironment | initialEnvironment | The environment from which to begin the search. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Solution> | An asynchronous result that yields either the one solution, if found, or |
FindSingleSolution(IEnvironment)
Method that searches for a single solution to the puzzle according to its description and the provided parameters, and asserts there is no other solution.
Declaration
public Solution FindSingleSolution(IEnvironment initialEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironment | initialEnvironment | The environment from which to begin the search. |
Returns
| Type | Description |
|---|---|
| Solution | The single solution, if found, or |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown if more than one solution is found. |
FindSingleSolutionAsync(IEnvironment)
Asynchronous method that searches for a single solution to the puzzle according to its description and the provided parameters, and asserts there is no other solution. It wraps the FindSingleSolution(IEnvironment) method.
Declaration
public Task<Solution> FindSingleSolutionAsync(IEnvironment initialEnvironment)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnvironment | initialEnvironment | The environment from which to begin the search. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<Solution> | An asynchronous result that yields either the single solution, if found, or |
Exceptions
| Type | Condition |
|---|---|
| System.InvalidOperationException | Thrown if more than one solution is found. |