| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include "IndirectSequence.hpp" | ||
| 4 | #include <memory> | ||
| 5 | #include <vector> | ||
| 6 | |||
| 7 | template <typename P> | ||
| 8 | using PointerVector = IndirectSequence<std::vector<P>>; | ||
| 9 | |||
| 10 | template <typename T> | ||
| 11 | using RawPointerVector = PointerVector<T*>; | ||
| 12 | |||
| 13 | template <typename T> | ||
| 14 | using UniquePointerVector = PointerVector<std::unique_ptr<T>>; | ||
| 15 | |||
| 16 | template <typename T> | ||
| 17 | using SharedPointerVector = PointerVector<std::shared_ptr<T>>; | ||
| 18 | |||
| 19 | template <typename T, typename... Args> | ||
| 20 | void emplaceBack(UniquePointerVector<T>& v, Args&&... args) { | ||
| 21 | v.emplace_back(std::make_unique<T>(std::forward<Args>(args)...)); | ||
| 22 | } | ||
| 23 | |||
| 24 | template <typename T, typename... Args> | ||
| 25 | void emplaceBack(SharedPointerVector<T>& v, Args&&... args) { | ||
| 26 | v.emplace_back(std::make_shared<T>(std::forward<Args>(args)...)); | ||
| 27 | } | ||
| 28 | |||
| 29 | template <typename S> | ||
| 30 | 5 | RawPointerVector<typename S::value_type> reference(S& sequence) { | |
| 31 | 5 | auto result = RawPointerVector<typename S::value_type>{}; | |
| 32 |
1/2✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
5 | result.base.reserve(sequence.size()); |
| 33 |
7/12✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 7 taken 14 times.
✗ Branch 8 not taken.
✓ Branch 14 taken 14 times.
✗ Branch 15 not taken.
✓ Branch 18 taken 14 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 19 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 14 times.
✓ Branch 24 taken 5 times.
|
19 | for (auto& element : sequence) { result.base.emplace_back(&element); } |
| 34 | 5 | return result; | |
| 35 | ✗ | } | |
| 36 | |||
| 37 | template <typename S> | ||
| 38 | const RawPointerVector<typename S::value_type> reference(const S& sequence) { | ||
| 39 | return const_cast<const RawPointerVector<typename S::value_type>>( | ||
| 40 | reference(const_cast<S&>(sequence))); // NOLINT(*-const-cast) | ||
| 41 | } | ||
| 42 | |||
| 43 | template <typename S> | ||
| 44 | 1 | RawPointerVector<typename S::value_type> mask( | |
| 45 | S& sequence, const std::vector<bool>& mask) { | ||
| 46 | 1 | auto result = RawPointerVector<typename S::value_type>{}; | |
| 47 | 1 | auto size = std::min(sequence.size(), mask.size()); | |
| 48 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | result.base.reserve(size); |
| 49 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | for (typename S::size_type i = 0; i < size; i++) { |
| 50 |
3/4✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
3 | if (mask[i]) { result.base.push_back(&sequence[i]); } |
| 51 | } | ||
| 52 | 1 | return result; | |
| 53 | ✗ | } | |
| 54 | |||
| 55 | template <typename S> | ||
| 56 | const RawPointerVector<typename S::value_type> mask( | ||
| 57 | const S& sequence, const std::vector<bool>& mask) { | ||
| 58 | return const_cast<const RawPointerVector<typename S::value_type>>( | ||
| 59 | mask(const_cast<S&>(sequence), mask)); // NOLINT(*-const-cast) | ||
| 60 | } | ||
| 61 |