|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Collector that stores accepted solutions in an Aleph list. More...
#include <state_search_common.H>
Public Types | |
| using | Solution_Type = Solution |
| Type of collected solutions. | |
| using | Container_Type = DynList< Solution > |
| Internal container type. | |
Public Member Functions | |
| SearchSolutionCollector ()=default | |
| Build a collector with no limit. | |
| SearchSolutionCollector (const size_t max_solutions) | |
Build a collector that stops after max_solutions. | |
| SearchSolutionCollector (const SearchSolutionCollector &other)=default | |
| Copy the solutions and the limit of another collector. | |
| SearchSolutionCollector (SearchSolutionCollector &&other) noexcept | |
| Take the solutions of another collector, which is left empty, with the same limit. | |
| SearchSolutionCollector & | operator= (const SearchSolutionCollector &other)=default |
| Copy the solutions and the limit of another collector. | |
| SearchSolutionCollector & | operator= (SearchSolutionCollector &&other) noexcept |
| Exchange this collector with another, which is left with the previous solutions and limit of this one. | |
| void | swap (SearchSolutionCollector &other) noexcept |
| Exchange in O(1) the solutions and the limits of this collector and another. | |
| bool | operator() (const Solution &solution) |
| Append one solution and report whether enumeration should continue. | |
| void | clear () noexcept |
| Remove all collected solutions. | |
| size_t | size () const noexcept |
| Number of collected solutions. | |
| bool | is_empty () const noexcept |
Return true if no solution has been collected. | |
| const Container_Type & | solutions () const noexcept |
| Access the collected solutions. | |
| Container_Type & | solutions () noexcept |
| Mutable access to the collected solutions. | |
Private Attributes | |
| Container_Type | solutions_ |
| size_t | count_ = 0 |
| size_t | limit_ = Search_Unlimited |
Collector that stores accepted solutions in an Aleph list.
This is a small adapter for DFS/backtracking enumeration. It appends each accepted solution to an internal DynList and can optionally stop after a user-specified number of collected solutions.
| Solution | Type of solution to collect. |
Definition at line 386 of file state_search_common.H.
| using Aleph::SearchSolutionCollector< Solution >::Container_Type = DynList<Solution> |
Internal container type.
Definition at line 392 of file state_search_common.H.
| using Aleph::SearchSolutionCollector< Solution >::Solution_Type = Solution |
Type of collected solutions.
Definition at line 390 of file state_search_common.H.
|
default |
Build a collector with no limit.
|
inlineexplicit |
Build a collector that stops after max_solutions.
| max_solutions | Maximum number of solutions to store. |
Definition at line 400 of file state_search_common.H.
References ah_invalid_argument_if, and Aleph::SearchSolutionCollector< Solution >::limit_.
|
default |
Copy the solutions and the limit of another collector.
| [in] | other | collector to copy. |
| std::bad_alloc | if the solutions cannot be copied. |
|
inlinenoexcept |
Take the solutions of another collector, which is left empty, with the same limit.
The implicit move took the list but copied the count: the moved-from collector then reported solutions that it no longer had, and asked to stop at the first new one once the count had reached the limit.
| [in,out] | other | collector to move from. |
Definition at line 422 of file state_search_common.H.
|
inlinenoexcept |
Remove all collected solutions.
Definition at line 466 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::count_, Aleph::DynList< T >::empty(), and Aleph::SearchSolutionCollector< Solution >::solutions_.
Referenced by Moved_From_Case< Collector >::use().
|
inlinenoexcept |
Return true if no solution has been collected.
Definition at line 479 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::count_.
Referenced by Moved_From_Case< Collector >::is_empty(), TEST(), and Moved_From_Case< Collector >::use().
|
inline |
Append one solution and report whether enumeration should continue.
Definition at line 458 of file state_search_common.H.
References Aleph::DynList< T >::append(), Aleph::SearchSolutionCollector< Solution >::count_, Aleph::SearchSolutionCollector< Solution >::limit_, and Aleph::SearchSolutionCollector< Solution >::solutions_.
|
default |
Copy the solutions and the limit of another collector.
| [in] | other | collector to copy. |
| std::bad_alloc | if the solutions cannot be copied. |
|
inlinenoexcept |
Exchange this collector with another, which is left with the previous solutions and limit of this one.
| [in,out] | other | collector to move from. |
Definition at line 440 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::swap().
|
inlinenoexcept |
Number of collected solutions.
Definition at line 473 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::count_.
Referenced by Moved_From_Case< Collector >::is_empty(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), and Moved_From_Case< Collector >::use().
|
inlinenoexcept |
Access the collected solutions.
Definition at line 485 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::solutions_.
Referenced by Moved_From_Case< Collector >::is_empty(), main(), TEST(), TEST(), TEST(), and Moved_From_Case< Collector >::use().
|
inlinenoexcept |
Mutable access to the collected solutions.
Definition at line 491 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::solutions_.
|
inlinenoexcept |
Exchange in O(1) the solutions and the limits of this collector and another.
| [in,out] | other | collector to exchange with. |
Definition at line 450 of file state_search_common.H.
References Aleph::SearchSolutionCollector< Solution >::count_, Aleph::SearchSolutionCollector< Solution >::limit_, Aleph::SearchSolutionCollector< Solution >::solutions_, and Aleph::DynList< T >::swap().
Referenced by Aleph::SearchSolutionCollector< Solution >::operator=().
|
private |
Definition at line 498 of file state_search_common.H.
Referenced by Aleph::SearchSolutionCollector< Solution >::clear(), Aleph::SearchSolutionCollector< Solution >::is_empty(), Aleph::SearchSolutionCollector< Solution >::operator()(), Aleph::SearchSolutionCollector< Solution >::size(), and Aleph::SearchSolutionCollector< Solution >::swap().
|
private |
Definition at line 499 of file state_search_common.H.
Referenced by Aleph::SearchSolutionCollector< Solution >::SearchSolutionCollector(), Aleph::SearchSolutionCollector< Solution >::operator()(), and Aleph::SearchSolutionCollector< Solution >::swap().
|
private |
Definition at line 497 of file state_search_common.H.
Referenced by Aleph::SearchSolutionCollector< Solution >::clear(), Aleph::SearchSolutionCollector< Solution >::operator()(), Aleph::SearchSolutionCollector< Solution >::solutions(), Aleph::SearchSolutionCollector< Solution >::solutions(), and Aleph::SearchSolutionCollector< Solution >::swap().