ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
populators.hpp
1// This file is part of the ACTS project.
2//
3// Copyright (C) 2016 CERN for the benefit of the ACTS project
4//
5// This Source Code Form is subject to the terms of the Mozilla Public
6// License, v. 2.0. If a copy of the MPL was not distributed with this
7// file, You can obtain one at https://mozilla.org/MPL/2.0/.
8
9#pragma once
10
11// Project include(s).
12#include "detray/definitions/algorithms.hpp"
13#include "detray/definitions/detail/qualifiers.hpp"
14#include "detray/definitions/indexing.hpp"
15#include "detray/utils/invalid_values.hpp"
16
17namespace detray {
18
26template <bool kSORT = false>
27struct replace {
32 template <typename bin_t, typename content_t>
33 DETRAY_HOST_DEVICE void operator()(bin_t &&bin, content_t &&entry) const {
34 std::forward<bin_t>(bin).init(std::forward<content_t>(entry));
35
36 // Optionally sort the bin content
37 if constexpr (kSORT) {
38 detray::sequential_sort(std::forward<bin_t>(bin).begin(),
39 std::forward<bin_t>(bin).end());
40 }
41 }
42};
43
47template <bool kSORT = false>
48struct attach {
53 template <typename bin_t, typename entry_t>
54 DETRAY_HOST_DEVICE void operator()(bin_t &&bin, entry_t &&entry) const {
55 std::forward<bin_t>(bin).push_back(std::forward<entry_t>(entry));
56
57 // Optionally sort the bin content
58 if constexpr (kSORT) {
59 detray::sequential_sort(std::forward<bin_t>(bin).begin(),
60 std::forward<bin_t>(bin).end());
61 }
62 }
63};
64
69template <bool kSORT = false>
70struct complete {
75 template <typename bin_t, typename entry_t>
76 DETRAY_HOST_DEVICE void operator()(bin_t &&bin, entry_t &&entry) const {
77 for (dindex i{std::forward<bin_t>(bin).size()};
78 i < std::forward<bin_t>(bin).capacity(); ++i) {
79 std::forward<bin_t>(bin).push_back(std::forward<entry_t>(entry));
80 }
81
82 // Optionally sort the bin content
83 if constexpr (kSORT) {
84 detray::sequential_sort(std::forward<bin_t>(bin).begin(),
85 std::forward<bin_t>(bin).end());
86 }
87 }
88};
89
90} // namespace detray
Detray include(s).
Definition array_operators.hpp:18
unsigned int dindex
Default index type.
Definition indexing.hpp:18
void sequential_sort(rand_iter_t first, sentinel_t last)
sequential (single thread) sort function
Definition algorithms.hpp:29
An attach populator that adds a new entry to a given bin.
Definition populators.hpp:48
void operator()(bin_t &&bin, entry_t &&entry) const
Append a new entry to the bin - forwarding.
Definition populators.hpp:54
A complete populator that adds entries to a bin which contains an array of entries until it is comple...
Definition populators.hpp:70
void operator()(bin_t &&bin, entry_t &&entry) const
Complete the bin content with a new entry - forwarding.
Definition populators.hpp:76
A replace populator that overrides whatever current content is in the bin with a new entry.
Definition populators.hpp:27
void operator()(bin_t &&bin, content_t &&entry) const
Replace the bin content with a new entry - forwarding.
Definition populators.hpp:33