Algorithm-Statistic

 view release on metacpan or  search on metacpan

include/kth_order_statistic.hpp  view on Meta::CPAN

    typedef typename std::iterator_traits<InputIterator>::value_type T;

    size_t n = std::distance(begin, end);

    DEBUG("", std::endl);
    DEBUG_ITERABLE("Array", begin, end);
    DEBUG("k", k)
    DEBUG("n", n)

    if (n == 0)
        throw std::invalid_argument("Empty array passed");

    if ( k > n)
        throw std::invalid_argument("Bad argument k. Maybe it's out of range");

    auto it = begin,
         jt = end-1;

    auto pivot = begin + n/2;
    const T pivot_value = *pivot; 

    DEBUG("Pivot value", pivot_value);

    do {



( run in 0.447 second using v1.01-cache-2.11-cpan-496ff517765 )