Adiar  2.1.0
An External Memory Decision Diagram Library
Function Objects

The bridge between you and Adiar. More...

Function Objects

To bridge the gap between your algorithms and their data structures and the algorithms of Adiar, we use the abstract notion of predicate, consumer, and generator functions.

template<typename TypeSignature >
using adiar::function = std::function< TypeSignature >
 General-purpose polymorphic function wrapper. More...
 
template<typename... Args>
using adiar::predicate = function< bool(Args...)>
 Predicate function given value(s) of type(s) Args. More...
 
template<typename Arg >
using adiar::consumer = function< void(Arg)>
 Consumer function of value(s) of type(s) Args. More...
 
template<typename VarType >
using adiar::cost = function< double(VarType)>
 Cost function that assigns a cost to each variable. More...
 
template<typename RetType >
using adiar::generator = function< optional< RetType >()>
 Generator function that produces a new value of RetType for each call. More...
 
template<typename ValueType , typename OutputIt >
consumer< ValueType > adiar::make_consumer (OutputIt &iter)
 Wrap an iterator into a consumer function.
 
template<typename ValueType , typename OutputIt >
consumer< ValueType > adiar::make_consumer (OutputIt &&iter)
 Wrap an iterator into a consumer function.
 
template<typename OutputIt >
consumer< typename OutputIt::container_type::value_type > adiar::make_consumer (OutputIt &iter)
 Wrap an iterator into a consumer function.
 
template<typename OutputIt >
consumer< typename OutputIt::container_type::value_type > adiar::make_consumer (OutputIt &&iter)
 Wrap an iterator into a consumer function.
 
template<typename ForwardIt >
consumer< typename ForwardIt::value_type > adiar::make_consumer (ForwardIt &begin, ForwardIt &end)
 Wrap a begin and end iterator pair into a consumer function. More...
 
template<typename ForwardIt >
consumer< typename ForwardIt::value_type > adiar::make_consumer (ForwardIt &&begin, ForwardIt &&end)
 Wrap a begin and end iterator pair into a consumer function. More...
 
template<typename ForwardIt >
generator< typename ForwardIt::value_type > adiar::make_generator (ForwardIt &begin, ForwardIt &end)
 Wrap a begin and end iterator pair into a generator function.
 
template<typename ForwardIt >
generator< typename ForwardIt::value_type > adiar::make_generator (ForwardIt &&begin, ForwardIt &&end)
 Wrap a begin and end iterator pair into a generator function.
 
template<typename Stream >
generator< typename Stream::value_type > adiar::make_generator (Stream &s)
 Wrap an adiar::internal::file_stream into a generator function.
 
template<typename RetType >
generator< RetType > adiar::make_generator (const RetType &r)
 Wrap a single value into a generator.
 

Detailed Description

The bridge between you and Adiar.

Typedef Documentation

◆ consumer

template<typename Arg >
using adiar::consumer = typedef function<void(Arg)>

Consumer function of value(s) of type(s) Args.

Remarks
Most functions that provide values to a consumer will do so in a specific order; you may abuse this to improve the performance of your code.
Template Parameters
ArgsList of the argument's type in the order, they are supposed to be given.

◆ cost

template<typename VarType >
using adiar::cost = typedef function<double(VarType)>

Cost function that assigns a cost to each variable.

Template Parameters
VarTypeType of variable labels.

◆ function

template<typename TypeSignature >
using adiar::function = typedef std::function<TypeSignature>

General-purpose polymorphic function wrapper.

Template Parameters
TypeSignatureThe type signature of the form ret_t (args_t...).

◆ generator

template<typename RetType >
using adiar::generator = typedef function<optional<RetType>()>

Generator function that produces a new value of RetType for each call.

Remarks
Most functions that take a generator as the input expect it (1) to produce values in a specific order and (2) to provide a certain type of value to mark having reached the end. For (1), please see the documentation of each respective function, while for (2) use make_optional<T>().
Template Parameters
RetTypeType of each yielded value from the generator.

◆ predicate

template<typename... Args>
using adiar::predicate = typedef function<bool(Args...)>

Predicate function given value(s) of type(s) Args.

Template Parameters
ArgsList of the argument's type in the order, they are supposed to be given. This list may be empty.

Function Documentation

◆ make_consumer() [1/2]

template<typename ForwardIt >
consumer<typename ForwardIt::value_type> adiar::make_consumer ( ForwardIt &&  begin,
ForwardIt &&  end 
)
inline

Wrap a begin and end iterator pair into a consumer function.

Remarks
The resulting consumer function will throw an out_of_range if end is reached but more values are to be added, i.e. if the given range is not large enough for all values to be consumed.

◆ make_consumer() [2/2]

template<typename ForwardIt >
consumer<typename ForwardIt::value_type> adiar::make_consumer ( ForwardIt &  begin,
ForwardIt &  end 
)
inline

Wrap a begin and end iterator pair into a consumer function.

Remarks
The resulting consumer function will throw an out_of_range if end is reached but more values are to be added, i.e. if the given range is not large enough for all values to be consumed.