EnTT  3.0.0
algorithm.hpp
1 #ifndef ENTT_CORE_ALGORITHM_HPP
2 #define ENTT_CORE_ALGORITHM_HPP
3 
4 
5 #include <functional>
6 #include <algorithm>
7 #include <utility>
8 
9 
10 namespace entt {
11 
12 
21 struct std_sort {
35  template<typename It, typename Compare = std::less<>, typename... Args>
36  void operator()(It first, It last, Compare compare = Compare{}, Args &&... args) const {
37  std::sort(std::forward<Args>(args)..., std::move(first), std::move(last), std::move(compare));
38  }
39 };
40 
41 
55  template<typename It, typename Compare = std::less<>>
56  void operator()(It first, It last, Compare compare = Compare{}) const {
57  if(first != last) {
58  auto it = first + 1;
59 
60  while(it != last) {
61  auto pre = it++;
62  auto value = *pre;
63 
64  while(pre-- != first && compare(value, *pre)) {
65  *(pre+1) = *pre;
66  }
67 
68  *(pre+1) = value;
69  }
70  }
71  }
72 };
73 
74 
75 }
76 
77 
78 #endif // ENTT_CORE_ALGORITHM_HPP
EnTT default namespace.
Definition: algorithm.hpp:10
void operator()(It first, It last, Compare compare=Compare{}, Args &&... args) const
Sorts the elements in a range.
Definition: algorithm.hpp:36
void operator()(It first, It last, Compare compare=Compare{}) const
Sorts the elements in a range.
Definition: algorithm.hpp:56
Function object to wrap std::sort in a class type.
Definition: algorithm.hpp:21
Function object for performing insertion sort.
Definition: algorithm.hpp:43