Jpp
15.0.1-rc.2-highQE
the software that should make you happy
|
This class implements a merge and sort algorithm based on the divide-and-conquer concept. More...
#include <JMergeSort.hh>
Public Member Functions | |
JMergeSort () | |
Default constructor. More... | |
template<class JSuperContainer_t , template< class, class > class JContainer_t, class JAllocator_t > | |
void | operator() (const JSuperContainer_t &input, JContainer_t< JElement_t, JAllocator_t > &output) const |
Merge set of sorted data sets into single sorted data set. More... | |
template<class JSuperContainer_t , template< class, class > class JContainer_t, class JAllocator_t , class JComparator_t > | |
void | operator() (const JSuperContainer_t &input, JContainer_t< JElement_t, JAllocator_t > &output, const JComparator_t &comparator) const |
Merge set of sorted data sets into single sorted data set. More... | |
template<class T , template< class, class > class JContainer_t, class JAllocator_t > | |
void | operator() (T __begin, T __end, JContainer_t< JElement_t, JAllocator_t > &output) const |
Merge set of sorted data sets into single sorted data set. More... | |
template<class T , template< class, class > class JContainer_t, class JAllocator_t , class JComparator_t > | |
void | operator() (T __begin, T __end, JContainer_t< JElement_t, JAllocator_t > &output, const JComparator_t &comparator) const |
Merge set of sorted data sets into single sorted data set. More... | |
Private Types | |
typedef std::pair< std::vector < JElement_t >, std::vector < JElement_t > > | pair |
Private Member Functions | |
std::vector< JElement_t > & | getBuffer (const size_t level, const JTwosome side) const |
Get internal buffer. More... | |
template<class _Iterator_t , class JComparator_t > | |
void | merge (_Iterator_t __begin, _Iterator_t __end, const JComparator_t &comparator, const size_t level=0, const JTwosome side=LEFT) const |
Recursive merge. More... | |
Static Private Member Functions | |
template<class JContainer_t > | |
static void | copy (const JContainer_t &input, std::vector< JElement_t > &output) |
Fast copy of data set. More... | |
template<class JContainer_t , class JComparator_t > | |
static void | merge (const JContainer_t &first, const JContainer_t &second, std::vector< JElement_t > &output, const JComparator_t &comparator) |
Fast merge of two data sets into one data set. More... | |
Private Attributes | |
std::vector< pair > | buffer |
std::vector< JElement_t > | mirror |
This class implements a merge and sort algorithm based on the divide-and-conquer concept.
Note that this class heavily uses internal buffers. It should therefore be used as an I/O operator, rather than a constructor.
The template argument refers to the element of the input and output containers.
The input data containers should be compatible with that of STL containers, i.e provide for the following member methods:
typedef <constant iterator> const_iterator;
size_t size() const; // number of elements;
const_iterator begin() const; // begin of data const_iterator end() const; // end of data
The input should consist of a set of sorted data sets, each terminated by an end marker.
In this, an end marker corresponds to a value that is always larger than any physical value.
The end marker is the first element beyond the size but within the capacity of the container.
The output then consists of a single sorted data set which is also terminated by an end marker.
Definition at line 51 of file JMergeSort.hh.
|
private |
Definition at line 294 of file JMergeSort.hh.
|
inline |
|
inline |
Merge set of sorted data sets into single sorted data set.
input | input data sets |
output | output data set |
Definition at line 68 of file JMergeSort.hh.
|
inline |
Merge set of sorted data sets into single sorted data set.
input | input data sets |
output | output data set |
comparator | element comparator |
Definition at line 83 of file JMergeSort.hh.
|
inline |
Merge set of sorted data sets into single sorted data set.
__begin | begin of input data sets |
__end | end of input data sets |
output | output data set |
Definition at line 99 of file JMergeSort.hh.
|
inline |
Merge set of sorted data sets into single sorted data set.
__begin | begin of input data sets |
__end | end of input data sets |
output | output data set |
comparator | element comparator |
Definition at line 116 of file JMergeSort.hh.
|
inlinestaticprivate |
Fast copy of data set.
input | input data set |
output | output data set |
Definition at line 152 of file JMergeSort.hh.
|
inlinestaticprivate |
Fast merge of two data sets into one data set.
It is assumed that the input data sets are sorted and terminated by an end marker. In this, an end marker corresponds to a value that is larger than any physical value. The output data set will be terminated by the same end marker.
first | first data set |
second | second data set |
output | output data set |
comparator | element comparator |
Definition at line 184 of file JMergeSort.hh.
|
inlineprivate |
Get internal buffer.
level | depth in internal buffer |
side | either of two of a kind (left/right) |
Definition at line 220 of file JMergeSort.hh.
|
inlineprivate |
Recursive merge.
__begin | begin of set of data sets |
__end | end of set of data sets |
comparator | element comparator |
level | depth in internal buffer |
side | either of two of a kind (left/right) |
Definition at line 253 of file JMergeSort.hh.
|
mutableprivate |
Definition at line 296 of file JMergeSort.hh.
|
mutableprivate |
Definition at line 297 of file JMergeSort.hh.