Implementation of sequential and parallel multiway merge. More...
#include <vector>
#include <bits/stl_algo.h>
#include <parallel/features.h>
#include <parallel/parallel.h>
#include <parallel/losertree.h>
#include <parallel/multiseq_selection.h>
Namespaces | |
__gnu_parallel | |
GNU parallel code for public use. | |
Macros | |
#define | _GLIBCXX_PARALLEL_DECISION(__a, __b, __c, __d) |
#define | _GLIBCXX_PARALLEL_LENGTH(__s) ((__s).second - (__s).first) |
Length of a sequence described by a pair of iterators. More... | |
#define | _GLIBCXX_PARALLEL_MERGE_3_CASE(__a, __b, __c, __c0, __c1) |
#define | _GLIBCXX_PARALLEL_MERGE_4_CASE(__a, __b, __c, __d, __c0, __c1, __c2) |
Functions | |
template<typename _RAIter1 , typename _RAIter2 , typename _OutputIterator , typename _DifferenceTp , typename _Compare > | |
_OutputIterator | __gnu_parallel::__merge_advance (_RAIter1 &__begin1, _RAIter1 __end1, _RAIter2 &__begin2, _RAIter2 __end2, _OutputIterator __target, _DifferenceTp __max_length, _Compare __comp) |
Merge routine being able to merge only the __max_length smallest elements. More... | |
template<bool __stable, bool __sentinels, typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Compare > | |
_RAIter3 | __gnu_parallel::__sequential_multiway_merge (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits< typename std::iterator_traits< _RAIterIterator >::value_type::first_type >::value_type &__sentinel, _DifferenceTp __length, _Compare __comp) |
Sequential multi-way merging switch. More... | |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) |
Multiway Merge Frontend. More... | |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sampling_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag=parallel_tag(0)) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) |
template<template< typename RAI, typename C > class iterator, typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Compare > | |
_RAIter3 | __gnu_parallel::multiway_merge_3_variant (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) |
Highly efficient 3-way merging procedure. More... | |
template<template< typename RAI, typename C > class iterator, typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Compare > | |
_RAIter3 | __gnu_parallel::multiway_merge_4_variant (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) |
Highly efficient 4-way merging procedure. More... | |
template<bool __stable, typename _RAIterIterator , typename _Compare , typename _DifferenceType > | |
void | __gnu_parallel::multiway_merge_exact_splitting (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector< std::pair< _DifferenceType, _DifferenceType > > *__pieces) |
Exact splitting for parallel multiway-merge routine. More... | |
template<typename _LT , typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Compare > | |
_RAIter3 | __gnu_parallel::multiway_merge_loser_tree (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _DifferenceTp __length, _Compare __comp) |
Multi-way merging procedure for a high branching factor, guarded case. More... | |
template<typename UnguardedLoserTree , typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Compare > | |
_RAIter3 | __gnu_parallel::multiway_merge_loser_tree_sentinel (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits< typename std::iterator_traits< _RAIterIterator >::value_type::first_type >::value_type &__sentinel, _DifferenceTp __length, _Compare __comp) |
Multi-way merging procedure for a high branching factor, requiring sentinels to exist. More... | |
template<typename _LT , typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Compare > | |
_RAIter3 | __gnu_parallel::multiway_merge_loser_tree_unguarded (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, const typename std::iterator_traits< typename std::iterator_traits< _RAIterIterator >::value_type::first_type >::value_type &__sentinel, _DifferenceTp __length, _Compare __comp) |
Multi-way merging procedure for a high branching factor, unguarded case. More... | |
template<bool __stable, typename _RAIterIterator , typename _Compare , typename _DifferenceType > | |
void | __gnu_parallel::multiway_merge_sampling_splitting (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _DifferenceType __length, _DifferenceType __total_length, _Compare __comp, std::vector< std::pair< _DifferenceType, _DifferenceType > > *__pieces) |
Sampling based splitting for parallel multiway-merge routine. More... | |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) |
Multiway Merge Frontend. More... | |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, sampling_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag=parallel_tag(0)) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) |
template<bool __stable, bool __sentinels, typename _RAIterIterator , typename _RAIter3 , typename _DifferenceTp , typename _Splitter , typename _Compare > | |
_RAIter3 | __gnu_parallel::parallel_multiway_merge (_RAIterIterator __seqs_begin, _RAIterIterator __seqs_end, _RAIter3 __target, _Splitter __splitter, _DifferenceTp __length, _Compare __comp, _ThreadIndex __num_threads) |
Parallel multi-way merge routine. More... | |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, sampling_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag=parallel_tag(0)) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::sequential_tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, __gnu_parallel::exact_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, sampling_tag __tag) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, parallel_tag __tag=parallel_tag(0)) |
template<typename _RAIterPairIterator , typename _RAIterOut , typename _DifferenceTp , typename _Compare > | |
_RAIterOut | __gnu_parallel::stable_multiway_merge_sentinels (_RAIterPairIterator __seqs_begin, _RAIterPairIterator __seqs_end, _RAIterOut __target, _DifferenceTp __length, _Compare __comp, default_parallel_tag __tag) |
Implementation of sequential and parallel multiway merge.
Explanations on the high-speed merging routines in the appendix of
P. Sanders. Fast priority queues for cached memory. ACM Journal of Experimental Algorithmics, 5, 2000.
This file is a GNU parallel extension to the Standard C++ Library.
#define _GLIBCXX_PARALLEL_DECISION | ( | __a, | |
__b, | |||
__c, | |||
__d | |||
) |
Referenced by __gnu_parallel::multiway_merge_4_variant().
#define _GLIBCXX_PARALLEL_LENGTH | ( | __s | ) | ((__s).second - (__s).first) |
Length of a sequence described by a pair of iterators.
Referenced by __gnu_parallel::__sequential_multiway_merge(), __gnu_parallel::multiway_merge_exact_splitting(), __gnu_parallel::multiway_merge_loser_tree(), __gnu_parallel::multiway_merge_sampling_splitting(), and __gnu_parallel::parallel_multiway_merge().
#define _GLIBCXX_PARALLEL_MERGE_3_CASE | ( | __a, | |
__b, | |||
__c, | |||
__c0, | |||
__c1 | |||
) |
Referenced by __gnu_parallel::multiway_merge_3_variant().
#define _GLIBCXX_PARALLEL_MERGE_4_CASE | ( | __a, | |
__b, | |||
__c, | |||
__d, | |||
__c0, | |||
__c1, | |||
__c2 | |||
) |
Referenced by __gnu_parallel::multiway_merge_4_variant().