isort_array

2021年6月19日

sort_arrayは、挿入ソートアルゴリズムの実装です。operator []インターフェースのような配列を持つものはすべてソートされます。 

#include <dlib / sort.h>

    template <
        typename T,
        typename compare
        >
    void isort_array (
        T& array,
        unsigned long left,
        unsigned long right,
        const compare& comp 
    );
    /*!
        requires
            - T implements operator[]                                 
            - the items in array must be comparable by comp where comp is a function
              object with the same syntax as std::less<>
            - the items in array must be swappable by a global swap()   
            - left and right are within the bounds of array
              i.e. array[left] and array[right] are valid elements
            - left <= right
        ensures
            - for all elements in #array between and including left and right the 
              ith element is < the i+1 element
            - sorts using an insertion sort algorithm
    !*/

Posted by kinya