Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::ranges::sort

      From cppreference.com
      <cpp‎ |experimental‎ |ranges
       
       
       
       
      Algorithms library
      Non-modifying sequence operations
                                    
      Modifying sequence operations
                                    
      Partitioning operations
      Sorting operations
      Binary search operations
      Set operations (on sorted ranges)
                                    
      Heap operations
      Minimum/maximum operations
      Permutations
       
      template< RandomAccessIterator I, Sentinel<I> S,

               class Comp=ranges::less<>,class Proj=ranges::identity>
          requires Sortable<I, Comp, Proj>

      I sort( I first, S last, Comp comp= Comp{}, Proj proj= Proj{});
      (1)(ranges TS)
      template< RandomAccessRange R,

               class Comp=ranges::less<>,class Proj=ranges::identity>
          requires Sortable<ranges::iterator_t<R>, Comp, Proj>

      ranges::safe_iterator_t<R> sort( R&& r, Comp comp= Comp{}, Proj proj= Proj{});
      (2)(ranges TS)
      1) Sorts the elements in the range[firstlast) in ascending order. The order of equal elements is not guaranteed to be preserved. Elements are compared usingcomp after applying the projectionproj.
      2) Sorts the elements in the ranger, as if byreturnranges::sort(ranges::begin(r),ranges::end(r), comp, proj);.

      Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.

      Contents

      [edit]Parameters

      first, last - the range of elements to sort
      r - the range of elements to sort
      comp - the comparator to use
      proj - the projection to apply to elements in the range

      [edit]Return value

      An iterator pointing past the end of the range (i.e., it compares equal tolast for overload(1), andranges::end(r) for overload(2)).

      [edit]Complexity

      O(N·log(N)) comparisons, where N is equal to the number of elements in the range.

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      sorts a range into ascending order
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/ranges/algorithm/sort&oldid=155289"

      [8]ページ先頭

      ©2009-2025 Movatter.jp