Ponca  911e152b8d5ac5c934a260b3832f7f62800b65b9
Point Cloud Analysis library
Loading...
Searching...
No Matches
iteratorUtils.h
1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
11#pragma once
12
13#include "../defines.h"
14#include <algorithm>
15
17{
31 PONCA_MULTIARCH void fill(ForwardIt first, ForwardIt last, const T& value)
32 {
33#ifdef __CUDA_ARCH__
34 for (; first != last; ++first)
35 *first = value;
36#else
37 std::fill(first, last, value);
38#endif
39 }
40
56 {
57#ifdef __CUDA_ARCH__
59 typename std::iterator_traits<ForwardIt>::difference_type count, step;
60 count = last - first;
61
62 while (count > 0)
63 {
64 it = first;
65 step = count / 2;
66 it += step;
67
68 if (!comp(value, *it))
69 {
70 first = ++it;
71 count -= step + 1;
72 }
73 else
74 count = step;
75 }
76
77 return first;
78#else
79 return std::upper_bound(first, last, value, comp);
80#endif
81 }
82
96 template <class BidirIt1, class BidirIt2>
98 {
99#ifdef __CUDA_ARCH__
100 while (first != last)
101 *(--d_last) = *(--last);
102 return d_last;
103#else
104 return std::copy_backward(first, last, d_last);
105#endif
106 }
107} // namespace Ponca::internal
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:257
Copyright (c) 2022 Jacques-Olivier Lachaud (jacques-olivier.lachaud@univ-savoie.fr) Laboratory of Mat...
BidirIt2 copyBackward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last)
Copies the elements from the range [first, last) to another range ending at d_last.
void fill(ForwardIt first, ForwardIt last, const T &value)
Assigns the given value to all elements in the range [first, last).
ForwardIt upperBound(ForwardIt first, ForwardIt last, const T &value, Compare comp)
Searches for the first element in the partitioned range [first, last) which is ordered after value.