| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | |||
| 5 | #include "../Traits.h" | ||
| 6 | |||
| 7 | /** @private */ | ||
| 8 | namespace CXXIter::util { | ||
| 9 | |||
| 10 | /** | ||
| 11 | * @private | ||
| 12 | * @brief Internal advanceBy() implementation that eagerly pulls @p n elements from the pipeline. | ||
| 13 | * @param self Iterator pipeline. | ||
| 14 | * @param n Amounts to advance by. | ||
| 15 | * @return Amount of elements by which the iterator was actually advanced. | ||
| 16 | */ | ||
| 17 | template<typename TSelf> | ||
| 18 | 30 | static constexpr inline size_t advanceByPull(TSelf& self, size_t n) { | |
| 19 | 30 | size_t skipN = 0; | |
| 20 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
46 | while(skipN < n) { |
| 21 | 16 | trait::Iterator<TSelf>::next(self); | |
| 22 | 16 | skipN += 1; | |
| 23 | } | ||
| 24 | 30 | return skipN; | |
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * @private | ||
| 29 | * @brief Internal advanceBy() implementation that eagerly pulls @p n elements from the pipeline. | ||
| 30 | * @param self Iterator pipeline. | ||
| 31 | * @param n Amounts to advance by. | ||
| 32 | * @return Amount of elements by which the iterator was actually advanced. | ||
| 33 | */ | ||
| 34 | template<typename TSelf> | ||
| 35 | static constexpr inline size_t advanceByPullBack(TSelf& self, size_t n) { | ||
| 36 | size_t skipN = 0; | ||
| 37 | while(skipN < n) { | ||
| 38 | trait::Iterator<TSelf>::nextBack(self); | ||
| 39 | skipN += 1; | ||
| 40 | } | ||
| 41 | return skipN; | ||
| 42 | } | ||
| 43 | |||
| 44 | } | ||
| 45 |