Changeset 7ea90cf in mainline


Ignore:
Timestamp:
2018-07-05T21:41:22Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
65dde99
Parents:
b22ccaa
git-author:
Dzejrou <dzejrou@…> (2018-04-27 23:47:41)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:22)
Message:

cpp: added make-do sort for testing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/impl/algorithm.hpp

    rb22ccaa r7ea90cf  
    663663     */
    664664
    665     // TODO: implement
     665    template<class RandomAccessIterator, class Compare>
     666    void make_heap(RandomAccessIterator, RandomAccessIterator,
     667                   Compare);
     668
     669    template<class RandomAccessIterator, class Compare>
     670    void sort_heap(RandomAccessIterator, RandomAccessIterator,
     671                   Compare);
     672
     673    template<class RandomAccessIterator>
     674    void sort(RandomAccessIterator first, RandomAccessIterator last)
     675    {
     676        using value_type = typename iterator_traits<RandomAccessIterator>::value_type;
     677
     678        sort(first, last, less<value_type>{});
     679    }
     680
     681    template<class RandomAccessIterator, class Compare>
     682    void sort(RandomAccessIterator first, RandomAccessIterator last,
     683              Compare comp)
     684    {
     685        /**
     686         * Note: This isn't the most effective approach,
     687         *       but since we already have these two functions
     688         *       and they satisfy asymptotic limitations
     689         *       imposed by the standard, we're using them at
     690         *       the moment. Might be good to change it to qsort
     691         *       or merge sort later.
     692         */
     693
     694        make_heap(first, last, comp);
     695        sort_heap(first, last, comp);
     696    }
    666697
    667698    /**
Note: See TracChangeset for help on using the changeset viewer.