Quetzal-CoaTL
The Coalescence Template Library
Loading...
Searching...
No Matches
quetzal::coalescence::algorithm Namespace Reference

Generic algorithms for manipulating abstract coalescent trees. More...

Functions

template<class BidirectionalIterator , class T , class BinaryOperation , class Generator >
BidirectionalIterator binary_merge (BidirectionalIterator first, BidirectionalIterator last, T init, BinaryOperation op, Generator &g)
 merges 2 randomly selected elements in a range.
 
template<class BidirectionalIterator , class Generator >
BidirectionalIterator binary_merge (BidirectionalIterator first, BidirectionalIterator last, Generator &g)
 merges 2 randomly selected elements in a range, using sum operand between elements.
 
template<class BidirectionalIterator , class T , class BinaryOperation , class OccupancySpectrum , class Generator >
BidirectionalIterator simultaneous_multiple_merge (BidirectionalIterator first, BidirectionalIterator last, T init, OccupancySpectrum const &sp, BinaryOperation op, Generator &g)
 merges randomly selected elements in a range according to an occupancy spectrum.
 
template<class BidirectionalIterator , class OccupancySpectrum , class Generator >
BidirectionalIterator simultaneous_multiple_merge (BidirectionalIterator first, BidirectionalIterator last, OccupancySpectrum const &sp, Generator &g)
 merges randomly selected elements in a range according to an occupancy spectrum.
 

Detailed Description

Generic algorithms for manipulating abstract coalescent trees.

Function Documentation

◆ binary_merge() [1/2]

template<class BidirectionalIterator , class Generator >
BidirectionalIterator quetzal::coalescence::algorithm::binary_merge ( BidirectionalIterator  first,
BidirectionalIterator  last,
Generator &  g 
)

merges 2 randomly selected elements in a range, using sum operand between elements.

Parameters
firstiterator at the begin of the range
lastiterator to the past-the-end element.
ga random generator that must meet the requirements of UniformRandomBitGenerator concept.
Returns
An iterator to the element that follows the last element of the nodes remaining after coalescence. The function cannot alter the properties of the object containing the range of elements (i.e., it cannot alter the size of an array or a container): signaling the new size of the shortened range is done by returning an iterator to the element that should be considered its new past-the-end element. The range between first and this iterator includes all the remaining nodes in the sequence.
Remarks
the type T BidirectionalIterator::value_type must be defined.
the T default constructor is used to set the value at which the parent is initialized.
With a and b two objects of type T, the expression a + B must be defined.
BidirectionalIterator must meet the requirements of ValueSwappable and RandomAccessIterator.

◆ binary_merge() [2/2]

template<class BidirectionalIterator , class T , class BinaryOperation , class Generator >
BidirectionalIterator quetzal::coalescence::algorithm::binary_merge ( BidirectionalIterator  first,
BidirectionalIterator  last,
init,
BinaryOperation  op,
Generator &  g 
)

merges 2 randomly selected elements in a range.

Parameters
firstiterator at the begin of the range
lastiterator to the past-the-end element.
initthe value at which parent is initialized
opbinary operation function object that will be applied for branching a child to its parent. The binary operator takes the parent value a (initialized to init) and the value of the child b. The signature of the function should be equivalent to the following: Ret fun(const Type1 &parent, const Type2 &child);
ga random generator that must meet the requirements of UniformRandomBitGenerator concept.
Returns
An iterator to the element that follows the last element of the nodes remaining after coalescence. The function cannot alter the properties of the object containing the range of elements (i.e., it cannot alter the size of an array or a container): signaling the new size of the shortened range is done by returning an iterator to the element that should be considered its new past-the-end element. The range between first and this iterator includes all the remaining nodes in the sequence.
Remarks
BidirectionalIterator must meet the requirements of ValueSwappable and RandomAccessIterator.

◆ simultaneous_multiple_merge() [1/2]

template<class BidirectionalIterator , class OccupancySpectrum , class Generator >
BidirectionalIterator quetzal::coalescence::algorithm::simultaneous_multiple_merge ( BidirectionalIterator  first,
BidirectionalIterator  last,
OccupancySpectrum const &  sp,
Generator &  g 
)

merges randomly selected elements in a range according to an occupancy spectrum.

Parameters
firstiterator at the begin of the range
lastiterator to the past-the-end element.
spoccupancy spectrum giving the merging configuration
ga random generator that must meet the requirements of UniformRandomBitGenerator concept.
Returns
An iterator to the element that follows the last element of the nodes remaining after coalescence. The function cannot alter the properties of the object containing the range of elements (i.e., it cannot alter the size of an array or a container): signaling the new size of the shortened range is done by returning an iterator to the element that should be considered its new past-the-end element. The range between first and this iterator includes all the remaining nodes in the sequence.
Remarks
The type T BidirectionalIterator::value_type must be defined.
The T default constructor is used to set the value at which the parent is initialized.
With a and b two objects of type T, the expression a + b must be defined.
BidirectionalIterator must meet the requirements of ValueSwappable and RandomAccessIterator.

◆ simultaneous_multiple_merge() [2/2]

template<class BidirectionalIterator , class T , class BinaryOperation , class OccupancySpectrum , class Generator >
BidirectionalIterator quetzal::coalescence::algorithm::simultaneous_multiple_merge ( BidirectionalIterator  first,
BidirectionalIterator  last,
init,
OccupancySpectrum const &  sp,
BinaryOperation  op,
Generator &  g 
)

merges randomly selected elements in a range according to an occupancy spectrum.

Parameters
firstiterator at the begin of the range
lastiterator to the past-the-end element.
initthe value at which parent is initialized
spoccupancy spectrum giving the merging configuration
opbinary operation function object that will be applied for branching a child to its parent. The binary operator takes the parent value a (initialized to init) and the value of the child b. The signature of the function should be equivalent to the following: Ret fun(const Type1 &parent, const Type2 &child);
ga random generator that must meet the requirements of UniformRandomBitGenerator concept.
Returns
An iterator to the element that follows the last element of the nodes remaining after coalescence. The function cannot alter the properties of the object containing the range of elements (i.e., it cannot alter the size of an array or a container): signaling the new size of the shortened range is done by returning an iterator to the element that should be considered its new past-the-end element. The range between first and this iterator includes all the remaining nodes in the sequence.
Remarks
BidirectionalIterator must meet the requirements of ValueSwappable and RandomAccessIterator.