1 #ifndef AI_TOOLBOX_UTILS_PRUNE_HEADER_FILE
2 #define AI_TOOLBOX_UTILS_PRUNE_HEADER_FILE
29 template <
typename Iterator,
typename P = std::
identity>
31 if ( std::distance(begin, end) < 2 )
return end;
34 while (optEnd < end) {
35 auto target = end - 1;
37 for (
auto iter = begin; iter < optEnd; ++iter) {
38 if (
dominates(std::invoke(p, *iter), std::invoke(p, *target))) {
48 while (helper != optEnd) {
51 if (
dominates(std::invoke(p, *helper), std::invoke(p, *target))) {
52 std::iter_swap(target, --end);
57 std::iter_swap(target, optEnd);
95 template <
typename Iterator,
typename P = std::
identity>
122 auto oldEnd = newBegin;
124 while (target > newBegin) {
135 bool isDominating =
false;
137 while (old > begin) {
140 if (!isDominating &&
dominates(std::invoke(p, *old), std::invoke(p, *target))) {
143 std::iter_swap(target, --end);
147 if (
dominates(std::invoke(p, *target), std::invoke(p, *old))) {
157 std::iter_swap(old, --oldEnd);
165 auto oldSwap = oldEnd, newSwap = end;
166 while (newSwap > newBegin && oldSwap < newBegin)
167 std::iter_swap(--newSwap, oldSwap++);
169 return {oldEnd, newSwap == newBegin ? oldSwap : newSwap, end};
196 template <
typename It,
typename P = std::
identity>
207 template <
typename It,
typename P>
212 const size_t size = std::distance(begin, end);
213 if ( size < 2 )
return end;
231 for (
auto it = begin; it != bound; ++it )
244 while ( bound < end ) {
245 const auto witness = lp_.
findWitness(std::invoke(p, *(end-1)));