Classes | Functions
PLMD::mergeVectorTools Namespace Reference

Classes

struct  has_size_and_data
 
struct  has_size_and_data< T, std::void_t< decltype(std::declval< T >().size()), decltype(std::declval< T >().data())> >
 

Functions

template<class C , class D >
auto mergeSortedVectors (C &vecs, std::vector< D > &result) -> typename std::enable_if< has_size_and_data< C >::value, void >::type
 
template<class C >
static void mergeSortedVectors (const C *const *vecs, std::size_t size, std::vector< typename C::value_type > &result)
 Merge sorted vectors. More...
 

Function Documentation

◆ mergeSortedVectors() [1/2]

template<class C , class D >
auto PLMD::mergeVectorTools::mergeSortedVectors ( C &  vecs,
std::vector< D > &  result 
) -> typename std::enable_if<has_size_and_data<C>::value, void>::type

◆ mergeSortedVectors() [2/2]

template<class C >
static void PLMD::mergeVectorTools::mergeSortedVectors ( const C *const *  vecs,
std::size_t  size,
std::vector< typename C::value_type > &  result 
)
static

Merge sorted vectors.

Takes a vector of pointers to containers and merge them. Containers should be already sorted. The content is appended to the result vector. Optionally, uses a priority_queue implementation.

local class storing the range of remaining objects to be pushed

check if this vector still contains something to be pushed

to allow using a priority_queu, which selects the highest element. we here (counterintuitively) define < as >