Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::SearchSolutionCollector< Solution > Class Template Reference

Collector that stores accepted solutions in an Aleph list. More...

#include <state_search_common.H>

Collaboration diagram for Aleph::SearchSolutionCollector< Solution >:
[legend]

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.
 
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_Typesolutions () const noexcept
 Access the collected solutions.
 
Container_Typesolutions () noexcept
 Mutable access to the collected solutions.
 

Private Attributes

Container_Type solutions_
 
size_t count_ = 0
 
size_t limit_ = Search_Unlimited
 

Detailed Description

template<typename Solution>
class Aleph::SearchSolutionCollector< Solution >

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.

Template Parameters
SolutionType of solution to collect.

Definition at line 383 of file state_search_common.H.

Member Typedef Documentation

◆ Container_Type

template<typename Solution >
using Aleph::SearchSolutionCollector< Solution >::Container_Type = DynList<Solution>

Internal container type.

Definition at line 389 of file state_search_common.H.

◆ Solution_Type

template<typename Solution >
using Aleph::SearchSolutionCollector< Solution >::Solution_Type = Solution

Type of collected solutions.

Definition at line 387 of file state_search_common.H.

Constructor & Destructor Documentation

◆ SearchSolutionCollector() [1/2]

template<typename Solution >
Aleph::SearchSolutionCollector< Solution >::SearchSolutionCollector ( )
default

Build a collector with no limit.

◆ SearchSolutionCollector() [2/2]

template<typename Solution >
Aleph::SearchSolutionCollector< Solution >::SearchSolutionCollector ( const size_t  max_solutions)
inlineexplicit

Build a collector that stops after max_solutions.

Parameters
max_solutionsMaximum number of solutions to store.

Definition at line 397 of file state_search_common.H.

References ah_invalid_argument_if, and Aleph::SearchSolutionCollector< Solution >::limit_.

Member Function Documentation

◆ clear()

template<typename Solution >
void Aleph::SearchSolutionCollector< Solution >::clear ( )
inlinenoexcept

◆ is_empty()

template<typename Solution >
bool Aleph::SearchSolutionCollector< Solution >::is_empty ( ) const
inlinenoexcept

Return true if no solution has been collected.

Definition at line 425 of file state_search_common.H.

References Aleph::SearchSolutionCollector< Solution >::count_.

◆ operator()()

template<typename Solution >
bool Aleph::SearchSolutionCollector< Solution >::operator() ( const Solution &  solution)
inline

◆ size()

template<typename Solution >
size_t Aleph::SearchSolutionCollector< Solution >::size ( ) const
inlinenoexcept

Number of collected solutions.

Definition at line 419 of file state_search_common.H.

References Aleph::SearchSolutionCollector< Solution >::count_.

◆ solutions() [1/2]

template<typename Solution >
const Container_Type & Aleph::SearchSolutionCollector< Solution >::solutions ( ) const
inlinenoexcept

Access the collected solutions.

Definition at line 431 of file state_search_common.H.

References Aleph::SearchSolutionCollector< Solution >::solutions_.

◆ solutions() [2/2]

template<typename Solution >
Container_Type & Aleph::SearchSolutionCollector< Solution >::solutions ( )
inlinenoexcept

Mutable access to the collected solutions.

Definition at line 437 of file state_search_common.H.

References Aleph::SearchSolutionCollector< Solution >::solutions_.

Member Data Documentation

◆ count_

◆ limit_

◆ solutions_


The documentation for this class was generated from the following file: